3: Installing Docker
There are lots of ways and places to install Docker. There’s Windows, Mac, and Linux. You can install in the cloud, on premises, and on your laptop. And there are manual installs, scripted installs, wizard-based installs…
But don’t let that scare you. They’re all really easy, and a simple search for “how to install docker on <insert your choice here>” will reveal up-to-date instructions that are easy to follow. As a result, we won’t waste too much space here. We’ll cover the following.
- Docker Desktop
- Windows
- MacOS
- Multipass
- Server installs on
- Linux
- Play with Docker
Docker Desktop
Docker Desktop is a desktop app from Docker, Inc. that makes it super-easy to work with containers. It includes the Docker engine, a slick UI, and an extension system with a marketplace. These extensions add some very useful features to Docker Desktop such as scanning images for vulnerabilities and making it easy to manage images and disk space.
Docker Desktop is free for educational purposes, but you’ll have to pay if you start using it for work and your company has over 250 employees or does more than $10M in annual revenue.
It runs on 64-bit versions of Windows 10, Windows 11, MacOS, and Linux.
Once installed, you have a fully working Docker environment that’s great for development, testing, and learning. It includes Docker Compose and you can even enable a single-node Kubernetes cluster if you need to learn Kubernetes.
Docker Desktop on Windows can run native Windows containers as well as Linux containers. Docker Desktop on Mac and Linux can only run Linux containers.
We’ll walk through the process of installing on Windows and MacOS.
Windows pre-reqs
Docker Desktop on Windows requires all of the following:
- 64-bit version of Windows 10/11
- Hardware virtualization support must be enabled in your system’s BIOS
- WSL 2
Be very careful changing anything in your system’s BIOS.
Installing Docker Desktop on Windows 10 and 11
Search the internet or ask your AI assistant how to “install Docker Desktop on Windows”. This will take you to the relevant download page where you can download the installer and follow the instructions. You may need to install and enable the WSL 2 backend (Windows Subsystem for Linux).
Once the installation is complete you may have to manually start Docker Desktop from the Windows Start menu. It may take a minute to start but you can watch the start progress via the animated whale icon on the Windows task bar at the bottom of the screen.
Once it’s up and running you can open a terminal and type some simple docker
commands.
Notice the output is showing OS/Arch: linux/amd64
for the Server component. This is because a default installation assumes you’ll be working with Linux containers.
You can easily switch to Windows containers by right-clicking the Docker whale icon in the Windows notifications tray and selecting Switch to Windows containers...
.
Be aware that any existing Linux containers will keep running in the background but you won’t be able to see or manage them until you switch back to Linux containers mode.
Run another docker version
command and look for the windows/amd64
line in the Server section of the output.
You can now run and manage Windows containers (containers running Windows applications).
Congratulations. You now have a working installation of Docker on your Windows machine.
Installing Docker Desktop on Mac
Docker Desktop for Mac is like Docker Desktop on Windows — a packaged product with a slick UI that gets you a single-engine installation of Docker that’s ideal for local development needs. You can also enable a single-node Kubernetes cluster.
Before proceeding with the installation, it’s worth noting that Docker Desktop on Mac installs all of the Docker engine components in a lightweight Linux VM that seamlessly exposes the API to your local Mac environment. This means you can open a terminal on your Mac and use the regular Docker commands without ever knowing it’s all running in a hidden VM. This is why Docker Desktop on Mac only work with Linux containers – it’s all running inside a Linux VM. This is fine as Linux is where most of the container action is.
Figure 3.1 shows the high-level architecture for Docker Desktop on Mac.
The simplest way to install Docker Desktop on your Mac is to search the web or ask your AI how to “install Docker Desktop on MacOS”. Follow the links to the download and then complete the simple installer.
Once the installation is complete you may have to manually start Docker Desktop from the MacOS Launchpad. It may take a minute to start but you can watch the animated Docker whale icon in the status bar at the top of your screen. Once it’s started you can click the whale icon to manage Docker Desktop.
Open a terminal window and run some regular Docker commands. Try the following.
Notice that the OS/Arch:
for the Server component is showing as linux/amd64
or linux/arm64
. This is because the daemon is running inside the Linux VM mentioned earlier. The Client component is a native Mac application and runs directly on the Mac OS Darwin kernel which is why it shows as either darwin/amd64
or darwin/arm64
.
You can now use Docker on your Mac.
Installing Docker with Multipass
Multipass is a free tool for creating cloud-style Linux VMs on your Linux, Mac, or Windows machine. It’s my go-to choice for Docker testing on my laptop as it’s incredibly easy to spin-up and tear-down Docker VMs.
Just go to https://multipass.run/install
and install the right edition for your hardware and OS.
Once installed you’ll only need the following three commands:
Let’s see how to launch and connect to a new VM that will have Docker pre-installed.
Run the following command to create a new VM called node1 based on the docker image. The docker image has Docker pre-installed and ready to go.
It’ll take a minute or two to download the image and launch the VM.
List VMs to make sure it launched properly.
You’ll use the 192
IP address when working with the examples later in the book.
Connect to the VM with the following command.
You’re now logged on to the VM and can run regular Docker commands.
Just type exit
to log out of the VM. Use multipass delete node1
and then multipass purge
to delete it.
Installing Docker on Linux
There are lots of ways to install Docker on Linux and most of them are easy. The recommended way is to search the web or ask your AI how to do it. The instructions in this section may be out of date and just for guidance purposes.
In this section we’ll look at one of the ways to install Docker on Ubuntu Linux 22.04 LTS. The procedure assumes you’ve already installed Linux and are logged on.
- Remove existing Docker packages.
- Update the apt package index.
- Add the Docker GPG kye.
- Set-up the repository.
- Install Docker from the official repo.
Docker is now installed and you can test by running some commands.
Play with Docker
Play with Docker (PWD) is a fully functional internet-based Docker playground that lasts for 4 hours. You can add multiple nodes and even cluster them in a swarm.
Sometimes performance can be slow, but for a free service it’s excellent!
Visit https://labs.play-with-docker.com/
Chapter Summary
You can run Docker almost anywhere and most of the installation methods are simple.
Docker Desktop provides you a fully-functional Docker environment on your Linux, Mac, or Windows machine. It’s easy to install, includes the Docker engine, has a slick UI, and has a marketplace with lots of extensions to extend its capabilities. It’s a great choice for a local Docker development environment and even lets you spin-up a single-node Kubernetes cluster.
Packages exist to install the Docker engine on most Linux distros.
Play with Docker is a free 4-hour Docker playground on the internet.