140

I am using macOS 10.14.6 and docker info shows me that the docker daemon is not running.

How do I start the docker daemon from terminal?

I have not found any information on doing so anywhere. On Linux you do something like sudo service docker stop, but this is incompatible with MacOS.

2

6 Answers 6

92

An alternative solution is to use other runtime for docker. For example colima

brew install colima
colima start
docker ps -a

Since docker desktop isn't free for enterprise usage, the alternative runtime is a good option.

NOTE: if you've previously used Docker Desktop for launching Docker daemon and had an export of DOCKER_HOST defined in your user's shell configuration (.bash_profile, .zsh_profile etc.), you need to re-specify DOCKER_HOST to make sure it points to .colima directory and commands like docker-compose up -d work properly.

Example:

export DOCKER_HOST=unix:///$HOME/.colima/docker.sock
3
  • 2
    rancherdesktop.io is another option, offering less functionalities than docker desktop though Commented Mar 6, 2023 at 10:14
  • This one was the only solution on MacOs. Thanks a lot!
    – Shtefan
    Commented Mar 23, 2023 at 2:10
  • Thanks. Before, colima start, I had to run brew install docker. And then, everything went fine. Commented Oct 7, 2023 at 4:26
77

The docker setup does not work as in a normal Linux machine, on a Mac it is much more complicated. But it can be done!

  1. brew install --cask docker virtualbox
  2. brew install docker-machine
  3. docker-machine create --driver virtualbox default
  4. docker-machine restart
  5. eval "$(docker-machine env default)" # This might throw an TSI connection error. In that case run docker-machine regenerate-certs default
  6. (docker-machine restart) # maybe needed
  7. docker run hello-world

These steps are based on information given in these two questions:

5
  • 2
    I tried this and at the docker-machine create step it just got hung up "waiting for an IP" indefinitely, left the machine / VM in a locked unusable state. Commented Oct 23, 2020 at 19:48
  • 3
    I tried these instructions, but the docker daemon still wasn't started... To resolve the problem I had to use open --background -a Docker on my macbook... Commented Aug 18, 2021 at 0:06
  • 3
    Instead of brew install --cask docker virtualbox, I had to do brew install --cask virtualbox. Otherwise, when later running docker-machine create --driver virtualbox default, I got Error with pre-create check: "VBoxManage not found. Make sure VirtualBox is installed and VBoxManage is in the path", which indicates VirtualBox isn't properly installed.
    – yair
    Commented Sep 14, 2021 at 8:42
  • 1
    This went great for some time. But docker-machine was moved to maintenance in 2018, with a last release in 2019. They replaced it with Docker Desktop
    – NicolaeS
    Commented Jan 28, 2023 at 14:02
  • 2
    I tried that but it doesn't want to install virtualbox on an M1 processor based computer (which makes sense, since VB is Intel based). Commented Apr 19, 2023 at 0:49
42

Here is an alternative solution which worked for me:

  • remove docker and docker-compose installed by brew
  • install Docker Desktop for Mac or use brew install homebrew/cask/docker
  • run it and pass admin credentials to start everything

It resolved issues with "docker daemon not running" as well as some other issues that the other answer didn't (e.g. 0.0.0.0 ports were not redirected with docker installed using brew and worked smoothly with Docker Desktop installation).

0
31

If you have Docker Desktop installed, the docker daemon will be launched if you launch Docker Desktop.

To do that, you can run in Terminal:

open -a Docker

Also, if you don't like the window pop-up at startup, you can disable it by unchecking:

"Preferences" (via gear icon on the Docker Desktop window) -> "General" -> "Open Docker Dashboard at startup"

2
  • 2
    You have my vote already, but just for fun, and to save a precious keystroke, it works with a lower-case d too, i.e. open -a docker 😉 Commented Apr 25, 2023 at 8:25
  • 4
    Cool, it's so easy to remember too. Open a docker.
    – John Doe
    Commented Jul 6, 2023 at 22:43
3

Just install "Docker Desktop" and configure it to start when you log in.

1
  • Gotta love the simple answers. Not sure why I didn't think to look in settings earlier. Also +1 to @catwith for the comment about disabling the Docker dashboard window that opens on startup. Commented Jul 22, 2023 at 14:04
1

How do I start the docker daemon from terminal [ on MacOS ] ?

TL;DR

I use a combination of open, and docker info to start the docker daemon from terminal on MacOS.

open -a docker && while ! docker info > /dev/null 2>&1; do sleep 1 ; done

For the curious

First, we open the Docker application by passing docker to the -a or application flag of the open command.

open -a docker

For me, the engine takes a few seconds to actually boot, so I run docker info until it returns an exit code of 0 ( or success ).

while ! docker info; do sleep 1 ; done

Since I don't like seeing the terminal output while waiting, I redirect it to /dev/null. I want to capture errors and output alike, so I pass 2>&1 which says to send standard error and standard output to the same place.

> /dev/null 2>&1

Finally, we get the command.

open -a docker && while ! docker info > /dev/null 2>&1; do sleep 1 ; done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .