As part of my job at Workiva I work quite a bit with containers and I need to install Docker Desktop on my Mac running Big Sur. Instead of just downloading and installing the DMG from Docker, I instead wanted to install just the command line with Homebrew.
The first step, of course, is to install Homebrew. I won’t replicate those instructions here. Once you’ve done that and checked the installation, proceed with the following instructions.
Homebrew’s package index. Names: Docker Desktop, Docker Community Edition, Docker CE App to build and share containerized applications and microservices.
Install the actual docker and docker-machine packages using Homebrew:
Docker will need a virtualization system for running containers, I use virtualbox. Install it using Homebrew:
You may need to provide your administrator password to complete the installation. In addition, you will also probably need to allow the virtualbox system extension permission to run. A popup will open the Security & Privacy tab in System Preferences. Authenticate if needed and allow the extension to run. A restart will be required to load the extension.
The next step is to configure docker-machine to use virtualbox as the default virtualization environment:
After a bunch of output, a default configuration environment will be available, and the docker daemon will be running with the default environment. You can list the default machine with the
docker-machine ls command.
To configure the docker command which docker-machine instance to use, execute the following command in your terminal:
Finally, test to make sure that everything is installed correctly by running the hello-world container. Docker will download the container from Docker Hub and you should see output from the container:
I prefer to control when the docker-machine is running. Use the following commands to start and stop the background docker daemon:
I have a few aliases defined in my .zshrc to help control docker-machine and configure docker:
It’s always best to reconfigure docker after starting the machine in case new IP addresses have been allocated. Also, I prefer up and down instead of start and stop for some odd reason.