The platform known as Docker has become one of the most popular ways to run a new kind of software known as containerized apps. And while Docker's mainly aimed at programmer types, there are a few reasons why everyday Mac users might want it around as well.
What are containerized apps?
Containerized apps are tidy little packages of software that bundle nearly everything they need to run in a single, self-contained box.
Share and Collaborate with Docker Hub Docker Hub is the world’s largest repository of container images with an array of content sources including container community developers, open source projects and independent software vendors (ISV) building and distributing their code in containers.
Programmers can write an app once and know that it'll run anywhere, every time. Businesses get an efficient way to run lots of apps on a single server without straining their hardware. And users get apps that won't sprawl out and spread files into their hard drives' nooks and crannies, nor start hogging memory and slowing down the entire computer.
How does Docker work?
- Sep 06, 2016 Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
- Alla Kazakhian. Toronto, Canada Area Mental Health Clinician on the ACTT Hospital & Health Care Education State University of New York at Buffalo 2013 — 2015 Master's degree, Social Work George Brown College 2004 — 2005 Diploma, Mental Health, Addictions, Criminal Justice Pyatigorsk State Linguistic University (PSLU) 1996 — 2002 Master's degree, Germanic Languages, Literatures,.
Docker uses emulation to ensure that the same containerized app can run on any machine where Docker's installed. And because it emulates an operating system – usually some flavor of Linux, though you can also set it up to run enterprise versions of Windows – instead of actual chip hardware, it demands a lot less memory and processing power than traditional virtual machines like Parallels or VMware Fusion.
Unlike those apps, you can't use Docker to run Windows on your Mac – though you can run at least limited versions of Linux with it. And you can use Docker to run apps that weren't originally written for the Mac.
Once you fire up the easy-to-install Docker app, it runs in the background, and you can use the Terminal or another app called Kitematic (we'll get to that later) to install and run containerized apps.
Who is Docker for?
As mentioned above, Docker's mainly aimed at programmers who want to containerize existing apps or write new ones, and businesses and IT folks who want to use its industrial-grade software.
There are Docker versions of familiar desktop apps like Firefox, Chrome, Skype, Spotify, image editor GiMP, and audio editor Audacity. But most of these apps already have native Mac versions. Running them in containers only makes sense if you like the technical challenge, want to keep a single app from hogging all your system's memory, or want to ensure that any malware you might pick up while browsing the web stays stuck inside its container, unable to escape to the rest of your Mac.
As of this writing, the main reason I've found to run Docker on a Mac is Pi-hole, originally made for the Raspberry Pi. Pi-hole can automatically block Web ads across your entire home network, and Docker's the only way to get it working on a Mac without also having a Raspberry Pi.
How to install Docker on your Mac
1. Create a Docker Hub account
Docker Hub keeps track of the containers you're running (or creating) and provides a one-stop shop to find new ones. Sign up for a Docker account with a unique Docker ID, your email, and a strong password.
2. Download Docker Desktop for Mac
Once you've signed up and signed in to Docker Hub, get Docker Desktop for Mac. It's got everything you'll need to run Docker in one Mac-friendly installer. Your Mac needs to be running Mac OS Sierra or later, and have at least 4GB of RAM.
3. Install Docker Desktop on your Mac
Open the docker.dmg
file you downloaded, and drag the Docker app's cartoon whale icon into your Applications folder.
4. Open and run Docker
When you run the Docker app, a little whale icon will appear on the right side of the menubar atop your screen. It'll take a few minutes to get running, and Docker may ask your permission to use services on your computer. The app will also prompt you to enter the Docker ID and password you just created.
When containers stop appearing and disappearing atop the little whale icon in the menubar, and you see a green dot at the top of the Docker menu next to 'Docker Desktop is running,' you're all set.
Consult the Preferences in the Docker menu to control how big a chunk of your hard drive Docker's allotted, and how much of your memory and CPU it's allowed to use, among other options.
5. Download and install Kitematic
Kitematic lets you install, manage, and remove your Docker containers from a single graphical interface — a lifesaver if you're not familiar or comfortable with the Terminal. You can install, and later open, Kitematic directly from the Docker app's menu:
Follow the link in that dialog box to install Kitematic. The app may ask for — you guessed it — your Docker ID and password again, just to keep track of your containers.
From Kitematic, you can search for and install new containers, and delete, edit, stop, or restart existing ones. If a container's running, Kitematic gives you an easy way to view its log files, which aren't readily visible from the Terminal. The interface is fairly intuitive, so feel free to play around and see what you can do.
In my tests, Kitematic came in most useful for deleting troublesome containers whose installation I'd somehow botched. Just find the container in the list on the left side of the Kitematic window, click the X icon next to it, and the container's gone completely, for good. You can always reinstall a package, either from the Terminal or by searching for it in Kitematic, and try again.
Where can I learn more about Docker for Mac?
Consult Docker for Mac's help files for more information about getting started, ways to test that your installation's up and running smoothly, and more things you can do with Docker. There's also a guide to teach you how to create your own containerized apps.
For less technically inclined folks, it's tough to find a good list of desktop apps that work with Docker. Docker Hub doesn't break desktop apps into their own category, but Jessie Frazelle compiled this list in 2015.
Besides Pi-hole, do you have any favorite Docker containers that might benefit everyday Mac users? Ship them our way in the comments below.
macOS Catalina
Main
Money well spentYou can save the cost of a MacBook Air by buying a refurbished Mac Pro
Apple's current Mac Pro is now available as a refurbished item from apple.com.
Estimated reading time: 8 minutesIf you already have an installation of Docker Toolbox, read these topicsfirst to learn how Docker Desktop on Mac and Docker Toolbox differ, and how they cancoexist.
The Docker Toolbox environment
Docker Toolbox installs docker
, docker-compose
, and docker-machine
in/usr/local/bin
on your Mac. It also installs VirtualBox. At installation time,Toolbox uses docker-machine
to provision a VirtualBox VM called default
,running the boot2docker
Linux distribution, with Docker Enginewith certificates located on your Mac at$HOME/.docker/machine/machines/default
.
Before you use docker
or docker-compose
on your Mac, you typically use thecommand eval $(docker-machine env default)
to set environment variables sothat docker
or docker-compose
know how to talk to Docker Engine running onVirtualBox.
This setup is shown in the following diagram.
The Docker Desktop on Mac environment
Docker Desktop on Mac is a Mac-native application, that you install in /Applications
.At installation time, it creates symlinks in /usr/local/bin
for docker
anddocker-compose
and others, to the commands in the applicationbundle, in /Applications/Docker.app/Contents/Resources/bin
.
Here are some key points to know about Docker Desktop on Mac before you get started:
Docker Desktop uses HyperKit instead of Virtual Box. Hyperkit is a lightweight macOS virtualization solution built on top of Hypervisor.framework in macOS 10.10 Yosemite and higher.
When you install Docker Desktop on Mac, machines created with Docker Machine are not affected.
Docker Desktop does not use
docker-machine
to provision its VM.The Docker Engine API is exposed on asocket available to the Mac host at/var/run/docker.sock
. This is thedefault location Docker and Docker Compose clients use to connect tothe Docker daemon, so you can usedocker
anddocker-compose
CLI commandson your Mac.
This setup is shown in the following diagram.
With Docker Desktop on Mac, you only get (and only usually need) one VM, managed by Docker Desktop. Docker Desktop automatically upgrades the Docker client and daemon when updates are available.
Also note that Docker Desktop can’t route traffic to containers, so you can’tdirectly access an exposed port on a running container from the hosting machine.
If you do need multiple VMs, such as when testing multi-node swarms, you cancontinue to use Docker Machine, which operates outside the scope of Docker Desktop. SeeDocker Toolbox and Docker Desktop coexistence.
Setting up to run Docker Desktop on Mac
Check whether Toolbox DOCKER environment variables are set:
If this command returns no output, you are ready to use Docker Desktop.
If it returns output (as shown in the example), unset the
DOCKER
environment variables to make the client talk to the Docker Desktop Engine (next step).Run the
unset
command on the followingDOCKER
environment variables tounset them in the current shell.
Now, this command should return no output.
If you are using a Bash shell, you can use unset ${!DOCKER_*}
to unset all DOCKER environment variables at once. (This does not work in other shells such as zsh
; you need to unset each variable individually.)
Note: If you have a shell script as part of your profile that sets theseDOCKER
environment variables automatically each time you open a commandwindow, then you need to unset these each time you want to use Docker Desktop.
If you install Docker Desktop on a machine where Docker Toolbox is installed..
Docker Desktop replaces the docker
and docker-compose
command lines in/usr/local/bin
with symlinks to its own versions.
See also Unset environment variables in the current shellin the Docker Machine topics.
Docker Toolbox and Docker Desktop coexistence
You can use Docker Desktop and Docker Toolbox together on the same machine. Whenyou want to use Docker Desktop make sure all DOCKER environment variables areunset. You can do this in bash with unset ${!DOCKER_*}
. When you want to useone of the VirtualBox VMs you have set with docker-machine
, just run a eval$(docker-machine env default)
(or the name of the machine you want to target).This switches the current command shell to talk to the specified Toolboxmachine.
This setup is represented in the following diagram.
Using different versions of Docker tools
The coexistence setup works as is as long as your VirtualBox VMs provisionedwith docker-machine
run the same version of Docker Engine as Docker Desktop.If you need to use VMs running older versions of Docker Engine, you can use atool like Docker Version Manager to manageseveral versions of docker client.
Checking component versions
Ideally, the Docker CLI client and Docker Engine should be the same version.Mismatches between client and server, and host machines you might havecreated with Docker Machine can cause problems (client can’t talk to the serveror host machines).
If you have already installed Docker Toolbox, and theninstalled Docker Desktop, you might get a newer version of the Docker client. Run docker version
in a command shell to see client and server versions. In this example, the client installed with Docker Desktop is Version: 19.03.1
and the server (which was installed earlier with Toolbox) is Version: 19.03.2
.
Also, if you created machines with Docker Machine (installed with Toolbox) thenupgraded or installed Docker Desktop, you might have machines running differentversions of Engine. Run docker-machine ls
to view version information for themachines you created. In this example, the DOCKER column shows that each machineis running a different version of server.
You might also run into a similar situation with Docker Universal Control Plane (UCP).
There are a few ways to address this problem and keep using your oldermachines. One solution is to use a version manager likeDVM.
Migrating from Docker Toolbox to Docker Desktop on Mac
Docker Desktop does not propose Toolbox image migration as part of itsinstaller since version 18.01.0. You can migrate existing DockerToolbox images with the scripts described below. (This migrationcannot merge images from both Docker and Toolbox: any existing Docker image isreplaced by the Toolbox images.)
Run the following shell commands in a terminal. You need a workingqemu-img
; it is part of the qemu package in both MacPorts and Brew:
First, find your Toolbox disk images. You probably have just one:~/.docker/machine/machines/default/disk.vmdk
.
Second, find out the location and format of the disk image used by your DockerDesktop.
In this case the format is raw
(it could have been qcow2
), and the locationis ~/Library/Containers/com.docker.docker/Data/vms/0/
.
Then:
- if your format is qcow2, run
- if your format is raw, run the following command. If you are short on diskspace, it is likely to fail.
Finally (optional), if you are done with Docker Toolbox, you may fullyuninstallit.
How do I uninstall Docker Toolbox?
Docker Container Tutorial
You might decide that you do not need Toolbox now that you have Docker Desktop,and want to uninstall it. For details on how to perform a clean uninstall ofToolbox on Mac, see How to uninstall Toolboxin the Toolbox Mac topics.