275

Trying to setup docker from brew, however the engine does not seem to be included in any of the any of the official formulas.

brew install docker-machine docker-compose

So these only installs the clients? Is there no keg with the engine/daemon?

0

8 Answers 8

548

The following steps work fine on macOS Sierra 10.12.4. Note that after brew installs Docker, the docker command (symbolic link) is not available at /usr/local/bin. Running the Docker app for the first time creates this symbolic link. See the detailed steps below.

  1. Install Docker.

    brew install --cask docker
    
  2. Launch Docker.

    • Press + Space to bring up Spotlight Search and enter Docker to launch Docker.
    • In the Docker needs privileged access dialog box, click OK.
    • Enter password and click OK.

    When Docker is launched in this manner, a Docker whale icon appears in the status menu. As soon as the whale icon appears, the symbolic links for docker, docker-compose, docker-credential-osxkeychain and docker-machine are created in /usr/local/bin.

    $ ls -l /usr/local/bin/docker*
    lrwxr-xr-x  1 susam  domain Users  67 Apr 12 14:14 /usr/local/bin/docker -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker
    lrwxr-xr-x  1 susam  domain Users  75 Apr 12 14:14 /usr/local/bin/docker-compose -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker-compose
    lrwxr-xr-x  1 susam  domain Users  90 Apr 12 14:14 /usr/local/bin/docker-credential-osxkeychain -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker-credential-osxkeychain
    lrwxr-xr-x  1 susam  domain Users  75 Apr 12 14:14 /usr/local/bin/docker-machine -> /Users/susam/Library/Group Containers/group.com.docker/bin/docker-machine
    
  3. Click on the docker whale icon in the status menu and wait for it to show Docker is running.

    enter image description here enter image description here

  1. Test that docker works fine.

    $ docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    78445dd45222: Pull complete
    Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
    Status: Downloaded newer image for hello-world:latest
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://cloud.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/engine/userguide/
    
    $ docker version
    Client:
     Version:      17.03.1-ce
     API version:  1.27
     Go version:   go1.7.5
     Git commit:   c6d412e
     Built:        Tue Mar 28 00:40:02 2017
     OS/Arch:      darwin/amd64
    
    Server:
     Version:      17.03.1-ce
     API version:  1.27 (minimum version 1.12)
     Go version:   go1.7.5
     Git commit:   c6d412e
     Built:        Fri Mar 24 00:00:50 2017
     OS/Arch:      linux/amd64
     Experimental: true
    
7
  • This is great! Now I'm just stuck at User X isn't part of the docker group. What's the current way to fix that?
    – Alper
    Jan 3, 2019 at 10:56
  • 2
    brew cask install docker command not work. it works brew install homebrew/cask/docker or brew install --cask docker docker install but its not showing in application by click command and space bar. May 21, 2021 at 18:50
  • 2
    is using brew to install docker really recommended or safe? Jun 6, 2022 at 17:30
  • 1
    this is a great answer, with a ton of transparency into the whole setup process. thank you! Apr 4 at 18:49
  • 2
    Docker CLI tools are installed under $HOME/.docker/bin -- so docker is not available on the CLI by default. You can update your PATH or go to Docker Desktop settings -> Advanced -> select "System (Requires password)"
    – northben
    Apr 11 at 16:32
327

Please try running

brew install docker

This will install the Docker engine, which will require Docker-Machine (+ VirtualBox) to run on the Mac.

If you want to install the newer Docker for Mac, which does not require virtualbox, you can install that through Homebrew's Cask:

brew install --cask docker 
open /Applications/Docker.app
16
  • 4
    I've updated my answer to show how to install Docker for Mac, which does not require VirtualBox or Docker-Machine.
    – nwinkler
    Nov 10, 2016 at 11:33
  • 2
    I can see that this gives me the entire desktop app. Is there no way to get the daemon+cli tools only, I want to run it on a "headless" OSX. Nov 10, 2016 at 11:57
  • 23
    @DavidKarlsson The GUI app is the "official" Docker app, Docker Inc. provies no headless package for Mac OS. However, the GUI app contains the command line utilities. If the brew cask install docker does not create symlinks in usr/local/bin you can create them yourself: ln -s /Applications/Docker.app/Contents/Resources/bin /usr/local/bin/docker
    – chiborg
    Jan 16, 2017 at 16:06
  • 20
    It is not necessary to create the symbolic links to docker binaries manually. Running Docker app for the first time creates these symbolic links. See my answer at stackoverflow.com/a/43365425/303363 for details.
    – Susam Pal
    Apr 12, 2017 at 9:29
  • 6
    brew cask install docker is deprecated and brew install docker installs docker CLI. To install the docker for desktop, run brew install --cask docker
    – vijaycs85
    Dec 27, 2020 at 19:40
47

To install Docker for Mac with homebrew:

brew install homebrew/cask/docker

To install the command line completion:

brew install bash-completion
brew install docker-completion
brew install docker-compose-completion
brew install docker-machine-completion
6
  • 12
    you don't want brew install docker -- this is not the same as brew cask install docker and installs different things @mimoralea Dec 5, 2018 at 21:10
  • 4
    Thanks for the heads-up: brew cask install docker && brew install bash-completion docker-completion docker-compose-completion docker-machine-completion
    – mimoralea
    Dec 6, 2018 at 16:49
  • Don't use docker-machine - it will gives you a lot of headache with network forwarding
    – Vlad
    Jan 7, 2019 at 20:40
  • 1
    @mimoralea I would suggest you delete your first comment, so everyone spots your second one :-) Feb 7, 2019 at 15:18
  • 2
    @IgorSerebryany why are they different? what is the difference between them? I would expect the docker daemon be there either way, and work cli - is the difference only that one (cask) has kitematic as well? Mar 5, 2019 at 16:57
13

Docker desktop will not be installed if you run brew install docker. If you've already installed it this way, first uninstall with brew uninstall docker.

To install Docker Desktop, run:

brew install homebrew/cask/docker

Launch docker from your /Applications folder once and enter your password, then you can run commands like docker --version to verify the CLI is working.

11

Docker Desktop for Mac is not a suitable choice for enterprise docker users as it requires a paid license to use. Rancher Desktop is a viable open-source alternative for Docker Desktop for all three major OS.

Since this question is specifically targeted at Mac OS users, I have added the steps to make it work on Mac OS.

  1. First install Docker using homebrew. brew install docker

  2. Install Rancher Desktop.

  3. In Kubernates Settings, change container runtime to dockerd.

Profit !

UPDATE: There's another open-source container runtime in the scene, named Colima (https://github.com/abiosoft/colima).

3
  • Does Rancher replace the need for docker-machine and hence obviates the need for virtualbox?
    – NeilG
    Jul 5, 2022 at 12:53
  • 1
    @NeilG Yes it does.
    – Pavindu
    Jul 5, 2022 at 13:14
  • 3
    Yes indeed. On an M1 Mac on version 12.4 Monterey the following commands worked: softwareupdate --install-rosetta - brew install docker - brew install --cask rancher - open /Applications/Rancher\ Desktop.app/ - docker run hello-world. I chose "dockerd (moby)" as the container runtime. I'm not sure if rosetta is required. I had already installed it and wasn't able to check whether it was required or not.
    – NeilG
    Jul 5, 2022 at 13:29
3

There is now alternative to Docker Desktop for Mac: colima

If you have Homebrew installed, you can install it using:

brew install colima docker
colima start

docker installs Docker client, while colima provides the daemon.

2

For reinstall docker, you should run:

brew reinstall homebrew/cask/docker
1
  • 3
    This didn't work for me, brew uninstall docker && brew install --cask docker worked for me. Apr 13, 2022 at 1:37
0

OrbStack provides an unmodified Docker engine, and thus Docker CLI. I've been using it on my M2 Pro successfully.


% docker version
Client:
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:28:49 2023
 OS/Arch:           darwin/arm64
 Context:           orbstack

Server: Docker Engine - Community
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:31:30 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          v1.7.6
  GitCommit:        091922f03c2762540fd057fba91260237ff86acb
 runc:
  Version:          1.1.9
  GitCommit:        82f18fe0e44a59034f3e1f45e475fa5636e539aa
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.