How to Install Docker Using Homebrew

Isaac Tony Feb 02, 2024
How to Install Docker Using Homebrew

Docker containers have, without a doubt, revolutionized the way we develop and deploy our applications. They provide developers with the ability to package applications and dependencies in an isolated environment.

We have seen widespread adoption of Docker as the ultimate containerization platform in the recent past. Due to this, setting up Docker across all platforms has incredibly been simplified, including macOS and Windows.

Use Homebrew to Install Docker in macOS

Docker supports the most recent versions of macOS, including macOS Big Sur, macOS Monterey, and macOS Catalina. Docker offers a native application that we can install under the Applications directory and create symlinks in /usr/local/bin.

Use Homebrew to install Docker. It’s an open-source software package management system that we can use to install applications on macOS.

Homebrew installs packages to their directory and then symlinks their files into /usr/local. Homebrew can be installed by running the command below in the terminal.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Now that Homebrew is installed to install Docker, execute the below command.

brew cask install docker

This command will download the docker package, run the Docker installer, and open the GUI to set up configurations. Use the command below to verify the installation was successful.

docker --version

As mentioned before, Homebrew installs packages to their directory and then symlinks their files into /usr/local (on macOS Intel). However, after Brew has installed Docker, the docker command (symbolic link) may not be available at /usr/local/bin.

To resolve this, follow the following steps.

  • Press +Space to open Spotlight Search, and enter Docker to launch Docker.
  • In the Docker needs privileged access dialog box, click OK.
  • Enter a password and click OK.
  • Once we have launched Docker, a whale-like icon should now be visible in the status menu. This means that all the symbolic files pointing to the location of Docker have been properly set up in /usr/local/bin.
  • You can confirm this by executing the command below in the terminal.

Code:

$ ls -l /usr/local/bin/docker*

Now click on the Docker icon and wait for Docker to start.

docker icon

Finally, we will run the command below to test that your Docker installation is properly set up.

$ docker run hello-world

Output:

docker hello world

We have pulled the hello-world image from the Docker registry and successfully created a Docker container with this command. This signifies that Docker is now properly set up in your system.

Author: Isaac Tony
Isaac Tony avatar Isaac Tony avatar

Isaac Tony is a professional software developer and technical writer fascinated by Tech and productivity. He helps large technical organizations communicate their message clearly through writing.

LinkedIn

Related Article - Docker MacOS