505

I normally prefer to manage my apps on my OSX with brew

I am able to install docker, docker-compose and docker-machine

docker --version
Docker version 17.05.0-ce, build 89658be
docker-compose --version
docker-compose version 1.13.0, build unknown
docker-machine --version
docker-machine version 0.11.0, build 5b27455

I did not download and run 'Docker for Mac' app.

However when I try to run

> docker run -d -p 80:80 --name webserver nginx
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

I have already checked the sock file

ls -lah /var/run/docker.sock /var/tmp/docker.sock
ls: /var/run/docker.sock: No such file or directory
ls: /var/tmp/docker.sock: No such file or directory

I have also tried this proposed solution: Mac OS X sudo docker Cannot connect to the Docker daemon. Is the docker daemon running on this host?

But I got this error message:

$ eval $(docker-machine env default)
Host does not exist: "default"

Is it possible to get a docker service to run by command line tools?

Community
  • 1
  • 1
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
  • 14
    Launch the Docker application from Launchpad, will be showing a dialog asking that for run the App, is necessary granted some privileged for this App, after this, the Docker is back to the game. – Rafael Kerr Jan 22 '18 at 00:19
  • In my case there was another user loggedin thats why it was failing. Logout other user and worked then – Raza Ahmed Jun 14 '19 at 17:33

34 Answers34

943

On a supported Mac, run:

brew install --cask docker

Then launch the Docker app. Click next. It will ask for privileged access. Confirm. A whale icon should appear in the top bar. Click it and wait for "Docker is running" to appear.

You should be able to run docker commands now:

docker ps

Because docker is a system-level package, you cannot install it using brew install, and must use --cask instead.

Note: This solution only works for Macs whose CPUs support virtualization, which may not include old Macs.

Edit 2022 - It was brought up in the comments section that there has been a licensing change for Docker Desktop. Please consider alternatives below, and check the comments for details.

friederbluemle
  • 33,549
  • 14
  • 108
  • 109
  • 25
    This should be the accepted answer. Go to the launch pad after install and search docker – Joe Lloyd Aug 14 '17 at 08:24
  • 70
    I did a brew install docker and the app wasn't installed until I ran the command brew cask install docker. Thanks! – jbrahy Sep 12 '17 at 21:09
  • 3
    What happens if the command still doesn't work even after the cask install (and Docker whale shows it's running after password given)? – vol7ron Mar 19 '18 at 03:13
  • @vol7ron Please be more specific. What does not work? Are you seeing any error messages etc? – friederbluemle Mar 23 '18 at 07:19
  • I forget exactly. The desktop app was running, but not loading a container. From the command line nothing worked or knew to reference that app — I’ll try again in the future to get you more specific information. Perhaps the other brewed non-cask items (docker, docker-machine, etc) need to first be uninstalled? – vol7ron Mar 23 '18 at 12:03
  • 1
    It just worked for me, but I ran `brew uninstall docker` before reinstalling with `brew cask install docker`. Then everything worked like a charm. – Michael Delgado Apr 11 '18 at 17:11
  • 2
    This solution only works for Macs whose CPUs support virtualisation. It does *not* work on a 2009 Mac Pro, for example. Could you please edit your answer to include this important fact? – John Y May 06 '18 at 09:34
  • `Error: It seems there is already an App at '/Applications/Docker.app'.` – arntg Jun 06 '18 at 06:58
  • 1
    launching docker pap did it for me – Bowofola Oct 23 '18 at 15:49
  • 5
    This is great and all; but is there no way to do this without getting into the GUI? `$ open /Applications/Docker.app` returns `LSOpenURLsWithRole() failed with error -10810 for the file /Applications/Docker.app.` – dlamblin Mar 05 '19 at 13:45
  • 1
    Anyone coming across this, heads up! This will kill your minikube's network settings. So if you are using minikube make sure you know this before going all cask install crazy. Wasted an hour fixing this. – akahunahi Apr 17 '19 at 00:40
  • But why should this be the accepted answer? It's a bunch of GUI add-ons without actually solving the problem through troubleshooting. I think @kenorb's answer should be the accepted one. – SDG Jun 23 '19 at 07:44
  • 2
    There are definite tradeoffs to using Docker Desktop with this approach [as stated here](https://docs.docker.com/docker-for-mac/docker-toolbox/). I believe this answer should be updated to indicate this. I personally chose not to use Docker Desktop, but to each their own. – Chris H. Oct 03 '19 at 22:38
  • @dlamblin try running this command `open --hide --background -a Docker` – Andrew Jun 22 '21 at 02:00
  • 2
    Now that there is a licensing change on Docker Desktop, this is not a good answer. – dres Sep 01 '21 at 12:22
  • @dres - Can you elaborate? How does the answer need to be updated? – friederbluemle Sep 01 '21 at 16:12
  • 7
    @friederbluemle https://docs.docker.com/desktop/mac/release-notes/#new references a new licensing model which requires organizations over a certain size to pay to use the GUI on Mac and Windows. The answer should really be more like https://stackoverflow.com/a/49719638/442837. I also wrote about problems on bigsur here https://mindhaus.medium.com/ditching-docker-for-desktop-on-macos-bf087d5f60f9 – dres Sep 02 '21 at 17:41
  • perfect instructions – eliahonader May 09 '22 at 01:36
  • This is the correct answer, especially for users do not want to tie themselves with Docker Desktop or wanted to use Docker together with Rancher Desktop – panza May 11 '22 at 11:10
  • 1
    does not seem to work anymore, I get `Error: It seems there is already a Binary at '/usr/local/share/zsh/site-functions/_docker'.` – user5359531 May 17 '22 at 14:46
  • 2
    @user5359531 if I am not wrong, you have installed docker earlier. Same issue happened with me. So I ran 'brew uninstall docker', before running 'brew install --cask docker'. – Biswarup Nath Jul 19 '22 at 11:44
  • Might be good to note that this method downloads and installs docker desktop. Which is a complete dumpster fire on mac, extremely unstable and prone to wiping everything. – Neal Nov 29 '22 at 12:29
  • Running `brew install --cask docker` prompts for a password. – Elijah Lynn Jun 28 '23 at 02:08
  • The password prompt was for my system password, because docker is rootful by default. DOh! – Elijah Lynn Jun 28 '23 at 20:35
270

On macOS the docker binary is only a client and you cannot use it to run the docker daemon, because Docker daemon uses Linux-specific kernel features, therefore you can’t run Docker natively in OS X. So you have to install docker-machine in order to create VM and attach to it.

Install docker-machine on macOS

If you don't have docker-machine command yet, install it by using one of the following methods:

  • Using Brew command: brew install docker-machine docker.

  • Manually from Releases page:

    $ curl -L https://github.com/docker/machine/releases/download/v0.16.1/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine
    $ chmod +x /usr/local/bin/docker-machine
    

See: Get started with Docker for Mac.

Install Virtualbox

docker-machine relies on VirtualBox being installed and will fail if this isn't the case. If you already have VirtualBox, you can skip this step.

  • Using Homebrew: brew install --cask virtualbox
  • Manually using the releases on Virtualbox.org

You will need to actively accept loading the Virtualbox kernel extension in the OS X Security panel and then proceed to restart the machine for the next commands not to fail with Error: VBoxNetAdpCtl: Error while adding new interface

Configure docker-machine on macOS

Create a default machine (if you don't have one, see: docker-machine ls):

docker-machine create --driver virtualbox default

Then set-up the environment for the Docker client:

eval "$(docker-machine env default)"

Then double-check by listing containers:

docker ps

See: Get started with Docker Machine and a local VM.


Related:

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
kenorb
  • 155,785
  • 88
  • 678
  • 743
  • 25
    this should be the accepted answer. It clearly outlines a) why it doesn't work, b) instructions to get it working without downloading the UI on OSX and c) reference links for further reading. – user2490003 Jun 20 '19 at 05:51
  • 1
    when you get all above staff done, you'd better add `eval "$(docker-machine env default)"` to your .*rc file of your shell(e.g. .zshrc, .bashrc) – xiaojueguan Nov 17 '20 at 04:40
  • Nice answer, while I'm a newbie, what's the purpose of running `eval "$(docker-machine env default)", and should I add this to my .zshrc file? – NeoZoom.lua Jun 11 '21 at 23:52
  • @xiaojueguan: Why? – NeoZoom.lua Jun 12 '21 at 00:02
  • 1
    I had to upvote this answer. Docker Desktop is licensed and there was change of Policy. It remains free for small businesses (fewer than 250 employees AND less than $10 million in annual revenue), personal use, education, and non-commercial open source projects. – Pavol Travnik Sep 22 '21 at 10:09
  • 3
    If you are on MacOS and using Virtualbox >=6.1.28 and you are receiving an error along the lines of: `VBoxManage: error: Code E_ACCESSDENIED (0x80070005) - Access denied (extended info not available) VBoxManage: error: Context: "EnableStaticIPConfig(Bstr(pszIp).raw(), Bstr(pszNetmask).raw())" at line 242 of file VBoxManageHostonly.cpp` [Then check out this answer](https://stackoverflow.com/questions/69722254/vagrant-up-failing-for-virtualbox-provider-with-e-accessdenied-on-host-only-netw) – Anthony Fammartino Dec 01 '21 at 21:18
  • 14
    Docker machine is now deprecated, it should be outlined in the answer https://docs.docker.com/machine/ – lvndry Dec 16 '21 at 09:23
  • 7
    Also it is not possible to install Virtualbox on ARM Macs... And as far as I can tell is not very likely to be possible. Basically it will support only ARM guest OSes (which is not terrible) or it has to emulate an Intel CPU which most likely will work awful. – skaurus Jul 22 '22 at 13:35
  • 1
    Virtualbox is now available as a Developer preview for macOS / Arm64 (M1/M2) macs : https://osxdaily.com/2022/10/22/you-can-now-run-virtualbox-on-apple-silicon-m1-m2/ – Roberto Tyley Nov 30 '22 at 17:11
  • I got: **Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?** – AnonymousUser Jan 18 '23 at 04:09
  • on osx 12.4 (monterey) got stucked here : docker-machine create --driver virtualbox default Running pre-create checks... Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory" – nicolas Jul 06 '23 at 16:25
103

If you wound up here after Docker Desktop 4.13.0 like me, it's because Docker got rid of the /var/run/docker.sock symlink in default behavior! See release notes here.

Quick fix: copy the command under "Permanent Solution" below

The Problem

I was experiencing docker ps (and other docker client commands) working, but other libraries that interact with docker (such as supabase CLI) resulted in:

$ supabase start
Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Solution

Now, you have to do something manual in order to get your tools to find the real docker socket file, which by default is at ~/Library/Containers/com.docker.docker/Data/docker.raw.sock.

Permanent Solution: Manually Symlink

This is a permanent solution that "undoes" this temporary fix.

sudo ln -s ~/Library/Containers/com.docker.docker/Data/docker.raw.sock /var/run/docker.sock
DOCKER_HOST=unix:///var/run/docker.sock docker ps # test that it works using linked socket file

Temporary Solution: Use DOCKER_HOST

This will temporarily get your command to use the new socket file

DOCKER_HOST=unix:///Users/$USER/Library/Containers/com.docker.docker/Data/docker.raw.sock docker ps

(replacing docker ps with whatever command you'd like, such as supabase start)

You can also make it work in your current terminal session, or paste into your .zshrc for always, with:

export DOCKER_HOST=unix:///Users/$USER/Library/Containers/com.docker.docker/Data/docker.raw.sock
Samuel Phan
  • 4,218
  • 2
  • 17
  • 18
efriis
  • 1,111
  • 1
  • 8
  • 7
  • 12
    This is the only answer that helped me on my M1 mac. – Dwayne Love Oct 22 '22 at 17:15
  • 1
    Great answer! maybe you should transform it into a new question for all those who recently installed supabase and encounter this error – Manu Oct 27 '22 at 15:57
  • 1
    Thanks a lot. I was getting "Cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running? (Details: [2] No such file or directory)" since I set up a fresh installation of Ventura and Docker. This gave me headache the whole day. I was about to give up when I stumbled over your answer. You should definitely transform this to a new question. Thx a lot. – hardy123480 Oct 28 '22 at 13:58
  • Thanks a lot! However, if someone else came here like me because of this issue in IntelliJ etc. then it's better to fix this in IntelliJ directly, see https://stackoverflow.com/a/74175227 – seveneights Oct 29 '22 at 12:24
  • Lifesaver, this worked by adding to my .zshrc! – Jordan Mar 22 '23 at 22:29
  • Perm solution doesnt work for me `sudo ln -s ~/Library/Containers/com.docker.docker/Data/docker.raw.sock /var/run/docker.sock ln: /var/run/docker.sock: File exists` You have to kill Docker Desktop first, then ` sudo rm /var/run/docker.sock`, run the fix and start Docker Desktop again. – Lukasz Madon Mar 29 '23 at 10:30
  • @LukaszMadon YES. Thank you: that was the only thing that worked for me, after all of the above. – rschwieb Apr 11 '23 at 03:41
  • I have two users on my machine (so, `/Users/$(whoami)` would differ), is there a "Permanent solution" for such a case? P.S.: the temporary solution was a life saver. Thanks a lot! – pilat Apr 23 '23 at 09:15
  • 2
    Hey folks! This should have been addressed in 4.13.1, so you shouldn't need to manually create the symlink anymore! If you're still experiencing this, I would recommend updating Docker and see if it resolves itself. https://docs.docker.com/desktop/release-notes/#4131 – efriis Apr 24 '23 at 18:51
  • 4.19 and still have this issue. Creating the symlink manually helped. – Aleš Oskar Kocur May 08 '23 at 09:29
  • 4.21 still has this issue and above 'permanent solution' works, which means you do have to manually create symlink if you didn't enable the default sock to be used ( uncheck in advance tab in docker desktop ) – Ross Bu Jun 12 '23 at 06:22
  • Ditto - I'm also running Docker 4.21.1 and the permanent solution here fixed my problem! Thanks @efriis! – Greg Sadetsky Jul 11 '23 at 21:09
51

I had this same issue I solved it in the following steps:

docker-machine restart

Quit terminal (or iTerm2, etc, etc) and restart

eval $(docker-machine env default)

I also answered it here

Master p
  • 826
  • 9
  • 8
34

docker-machine is now deprecated, I found Colima to be a great replacement and you can easily connect the docker daemon with a simple command:

brew install docker docker-compose colima
# make coffee
colima start

Ready to docker:

docker run hello-world
uɥƃnɐʌuop
  • 14,022
  • 5
  • 58
  • 61
32

I have Mac OS and I open Launchpad and select docker application. from reset tab click on restart.

Ehsan
  • 3,711
  • 27
  • 30
18

Try this to create default.

docker-machine create default
  • 5
    this just gave me ... docker-machine create default Creating CA: /Users/stens/.docker/machine/certs/ca.pem Creating client certificate: /Users/stens/.docker/machine/certs/cert.pem Running pre-create checks... Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path" .... which seems wrong since VirtualBox no longer is necessary to run docker on osx – Scott Stensland Jun 06 '17 at 00:54
  • Appears you can use `xhyve` as well, see https://stackoverflow.com/a/42419979/32453 or just install virtualbox :) – rogerdpack Jul 19 '18 at 18:02
  • And.. so what ? – FrankyFred Oct 26 '18 at 17:03
  • 1
    @FrankyFred OK I added an answer to attempt to clarify. – rogerdpack Sep 21 '20 at 19:38
  • `docker machine` is deprecated. the repo is locked. – J'e Jun 15 '22 at 15:03
15

For me Re-starting docker, didn't help. (Tried with both through terminal and UI)

The below option was unchecked, so I made it checked. After this I was able to run my container Setting -> Advanced -> Enabled default Docker socket(Requires Password)

Note - It will require admin Credentials.

enter image description here

Atiksha
  • 327
  • 4
  • 5
11

on OSX assure you have launched the Docker application before issuing

docker ps

or docker build ... etc ... yes it seems strange and somewhat misleading that issuing

docker --version

gives version even though the docker daemon is not running ... ditto for those other version cmds ... I just encountered exactly the same symptoms ... this behavior on OSX is different from on linux

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104
10

To extend other answers - after spending all morning on this exact issue and none of the other answers helped, finally I discovered that docker was trying to access the wrong path for docker.sock (!!) because some months ago I installed colima.

Running this helped me switch back:

docker context use default

high_byte
  • 261
  • 3
  • 7
  • I think this is what did it for me as well - I also had installed Colima a while back. But I needed to restart Docker and open a new terminal. Not sure both necessary, but it's working now. Thanks! – Andy Weinstein May 30 '23 at 10:22
9

Install minikube and come join the dark side.

https://kubernetes.io/docs/tasks/tools/install-minikube/

$ bash --version
GNU bash, version 5.0.3(1)-release (x86_64-apple-darwin18.2.0)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

eval $(minikube docker-env)

$ docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate     -i /local/swagger.json     -l python     -o /local/test/
[main] INFO io.swagger.parser.Swagger20Parser - reading from /local/swagger.json
[main] WARN io.swagger.codegen.DefaultGenerator - 'host' not defined in the spec. Default to 'localhost'.

Works great on Macbook Pro 2018 with bash v5. No need to install all the other docker nonsense these days IMO. The VM and install script that comes with minikube can replace docker machine from my experience.

akahunahi
  • 1,782
  • 23
  • 21
  • As a follow up comment, I needed docker as well for another project w/o kube and the docker desktop works great. Just don't start it up always or else kube gets angry from this post. – akahunahi Apr 24 '19 at 19:41
  • minikube and `eval $(minikube docker-env)` does not resolve the issue for me. – Ian Smith Dec 10 '21 at 00:04
  • Is Docker Desktop installed? Try using Wireshark to view the packets and connections. The `env` command will show the environment variables. That should give some insights on the macos networking layers. With minikube, the Kaniko builder is likely a better solution come 2022. – akahunahi Jan 15 '22 at 23:00
9

Just opening Docker Desktop worked for me.

arush436
  • 1,748
  • 20
  • 20
7

I had docker up to date, docker said it was running, and the diagnosis was good. I needed to unset some legacy environment variable (thanks https://docs.docker.com/docker-for-mac/troubleshoot/#workarounds-for-common-problems )

unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset DOCKER_TLS_VERIFY
Michael
  • 2,973
  • 1
  • 27
  • 67
7

This problem:

$ brew install docker docker-machine
$ docker ps

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

This apparently meant do the following:

$ docker-machine create default # default driver is apparently vbox:
Running pre-create checks...
Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path"
$  brew cask install virtualbox
…
$ docker-machine create default 
# works this time
$ docker ps
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
$ eval "$(docker-machine env default)"
$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

It finally works.

You can use the “xhyve” driver if you don’t want to install virtual box. Also you can install the “docker app” (then run it) which apparently makes it so you don’t have to run some of the above. brew cask install docker then run the app, see the other answers. But apparently isn't necessary per se.

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
7

This did the trick for me:

open --background -a Docker

Takes some seconds until you can connect to docker.

I am on a Mac OS Big Sur.

MattSt
  • 1,024
  • 2
  • 16
  • 35
5

I had the same problem. Docker running but couldn't access it through CLI.

For me the problem was solved by executing "Docker Quickstart Terminal.app". This is located in the "/Applications/Docker/" folder. As long as I work in this instance of the Terminal app Docker works perfectly. If a second window is needed I have to run the "Quickstart" app once more.

I have a Docker for Mac installation. Therefore I am not sure if my solution is valid for a Homebrew installation.

The "Docker Quickstart Terminal" app seems to be essentially some applescripts to launch the terminal app and a bash start script that initialise all the necessary environment variables.

Hope this helps someone else !

beo
  • 51
  • 1
  • 3
4

You should execute script for install docker and launch it from command line:

brew install --cask docker
sudo -H pip3 install --upgrade pip3
open -a Docker
docker-compose ... 

after that docker-compose should work

Boris Azanov
  • 4,408
  • 1
  • 15
  • 28
2

I was facing similar issue on my mac, and I found that docker wasn't running in my machine, I just went to applications and invoked whale and then it worked .

Rama Sharma
  • 96
  • 11
2

Docker was designed to run on Linux. It can, however, run in a VM on macOS. To do so is a bit of a kludge and that's perhaps why Docker Desktop exists in the first place. But that doesn't mean you can't enjoy using Docker from the comfort of the command line on a Mac.

Some options to consider:

  1. You could use lima and add an alias docker='lima nerdctl' to your bash profile.
  2. You could install a Linux VM on your machine and use it instead (not recommended).
  3. Dual-boot Linux on Mac. Even machines with the T2 and M1 chips are supported now.
StanleyZheng
  • 4,008
  • 3
  • 21
  • 24
vhs
  • 9,316
  • 3
  • 66
  • 70
2

The one hack which always works for me even on Mac Ventura 13.3.1 is

stop docker

Remove docker sock

sudo rm /var/run/docker.sock

Start docker again.

David
  • 887
  • 8
  • 7
1

With the updated version of VirtualBox (6.1.32r149290), the command docker-machine create --driver virtualbox default doesn't work, there is an error with auto-generated IP for the Virtual VM, explanation is here https://stackoverflow.com/a/69745931/2917630 .

This command helped me to resolve the issue: docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "192.168.59.3/24" default.

ultraon
  • 2,220
  • 2
  • 28
  • 27
1

Another solution for me (on the Apple Silicon) was to install rancher or Podman, but Podman has some issues while importing the libraries (i.e. paho_mqtt for Rust).

brew install rancher

Then starting the App and choose the service to start the VM.

Jan
  • 93
  • 9
1

I had the similar problem. And probably my particular case/solution can help others also.

Prerequisites:

I have MacOS (M1 chip) and installed Docker App. Docker Engine v20.10.23.

In my particular case I've tried to run spring-boot:build-image command in Maven with IntelijIdea to make a Docker Image for a service.

In response I had - [2] No such file or directory

And in IntelijIdea console I had - [INFO] I/O exception (java.io.IOException) caught when processing request to {}->docker://localhost:2376: com.sun.jna.LastErrorException: [2] No such file or directory

So, initially, I run in Mac terminal docker ps . It returned "Cannot connect to the Docker daemon at tcp://localhost:2376. Is the docker daemon running?"

Solution:

So I followed the next steps, as advised in another comments:

  1. run in terminal brew install --cask docker From the @friederbluemle answer above the explanation is next: "Because docker is a system-level package, you cannot install it using brew install, and must use --cask instead."

I suppose that initially I installed Docker with brew install, so probably it was the part of this issue.

  1. run Docker App
  2. run in terminal export DOCKER_HOST=unix:///var/run/docker.sock

After that when I run in terminal docker ps , it returned table columns CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES and command spring-boot:build-image works fine.

rsnlpn
  • 95
  • 1
  • 10
0

I first tried docker and docker-compose via homebrew, but it had the problem listed here. I had to install docker's official install from https://docs.docker.com/docker-for-mac/install/ and then everything worked as expected.

Thomas Kessler
  • 1,717
  • 3
  • 16
  • 27
0

i simply had to run spotlight search and execute the Docker application under /Applications folder which brew cask install created. Once this was run it asked to complete installation. I was then able to run docker ps

wired00
  • 13,930
  • 7
  • 70
  • 73
0

Tried the following and its working fine now

$ docker-machine create default
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Check network to re-create if needed...
(default) Found a new host-only adapter: "vboxnet0"
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!

Then

$ docker-machine env default

Finally

$ eval $(docker-machine env default)
$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
muTheTechie
  • 1,443
  • 17
  • 25
  • docker machine is deprecated. the repo is locked. The last update was more than 3 years ago – J'e Jun 15 '22 at 15:06
0

I run brew install docker-machine; then the problem is solved. The latest docker version does not have docker-machine included.

htlbydgod
  • 330
  • 2
  • 8
  • 1
    docker machine is deprecated – J'e Jun 15 '22 at 15:07
  • Docker machine is deprecated because docker.com only wants to support the proprietary docker desktop on mac. For medium-to-large companies, this involves substantial license fees. Use docker-machine as long as it works (or choose alternatives such as colima) if you work for such a company. – Yaakov Belch Jan 09 '23 at 20:59
0

Install Docker Desktop form given url

https://www.docker.com/products/docker-desktop/

Go to setting on top right corner

  • Goto General
  • Tick on Start Docker Desktop when you login you
Bijaya Kumar Oli
  • 2,007
  • 19
  • 15
0

If you are running into this issue with lima on Mac OSX, check to ensure the docker instance is running using limactl list. In my case the default instance was running but docker was not after a reboot. You may want to add limactl start docker into your Shell config, e.g. ~/.zshrc

➜ docker ps
Cannot connect to the Docker daemon at unix:///Users/xxxx/.lima/docker/sock/docker.sock. Is the docker daemon running?

➜ limactl list

NAME       STATUS     SSH                VMTYPE    ARCH      CPUS    MEMORY    DISK      DIR
default    Running    127.0.0.1:60022    qemu      x86_64    4       4GiB      100GiB    ~/.lima/default
docker     Stopped    127.0.0.1:50310    qemu      x86_64    4       4GiB      100GiB    ~/.lima/docker

➜ limactl start docker

...(lima log output)

➜ limactl list

NAME       STATUS     SSH                VMTYPE    ARCH      CPUS    MEMORY    DISK      DIR
default    Running    127.0.0.1:60022    qemu      x86_64    4       4GiB      100GiB    ~/.lima/default
docker     Running    127.0.0.1:50310    qemu      x86_64    4       4GiB      100GiB    ~/.lima/docker

➜ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
Ian Smith
  • 879
  • 1
  • 12
  • 23
0

Get the right link from https://www.docker.com/.

Either Intel chip or Mac chip. Then install manually.

It should work fine after that.

Nagmat
  • 373
  • 4
  • 14
0

My problem was resolved simply by running the following command on Ventura 13.0 (M2 Pro CPU Architecture), like the command working on Linux Distros:

sudo chown $USER /var/run/docker.sock

Then you should logout from your account or restarting Docker desktop and you can evaluate whether it works properly or not by executing docker ps command.

Mostafa Ghadimi
  • 5,883
  • 8
  • 64
  • 102
0

Input Command = docker ps

Output = Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

If this you facing on your Mac then follow the following steps.

  1. Start the docker application from Spotlight search
  2. Once docker is running then use docker ps or docker info command
Nilesh Shinde
  • 457
  • 5
  • 10
-1

installing docker-machine was enough for me to solve the problem.

ahmetbcakici
  • 363
  • 6
  • 17
-1

QUICK AND SIMPLE

Install Docker Desktop form given url

https://www.docker.com/products/docker-desktop/

Go to setting on top right corner

  • Goto General
  • Tick on Start Docker Desktop when you login you
Bijaya Kumar Oli
  • 2,007
  • 19
  • 15