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… There literally are loads of ways and places to install Docker.
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 installs on
- Windows 10
- Mac
- Server installs on
- Linux
- Windows Server 2019
- Play with Docker
Docker Desktop
Docker Desktop is a packaged product from Docker, Inc. It runs on 64-bit versions of Windows 10 and Mac, and it’s easy to download and install.
Once the installation is complete, you have a single-engine Docker environment that is great for development purposes. It includes Docker Compose and you can choose to enable a single-node Kubernetes cluster.
Early versions of Docker Desktop experienced some feature-lag while the product was developed with a stability first, features second approach. However, the product is now mature and a key technology in Docker, Inc’s focus on making it easier to get from the source code on your laptop to running applications in the cloud.
Docker Desktop on Windows 10 can run native Windows containers as well as Linux containers. Docker Desktop on Mac can only run Linux containers.
Windows pre-reqs
Docker Desktop on Windows requires all of the following:
- 64-bit version of Windows 10 Pro/Enterprise/Education (does not work with Home edition)
- Hardware virtualization support must be enabled in your system’s BIOS
- The Hyper-V and Containers features must be enabled in Windows
The installer can enable the Hyper-V and Containers features, but it’s your responsibility to enable hardware virtualization in your BIOS (be very careful changing anything in your system’s BIOS).
Installing Docker Desktop on Windows 10
Perform a google search for “install Docker Desktop”. This will take you to the relevant download page where you can download the installer and follow the instructions. It’s that simple!
At the time of writing, you can choose between the stable channel
and the edge channel
. The names are self-explanatory, with the edge channel
providing earlier access bleeding-edge features.
Once the installation is complete you may have to manually start Docker Desktop from the Windows Start menu. It can take a minute for it to start, and 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 PowerShell prompt 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. It does this by running the Docker daemon inside of a lightweight Linux Hyper-V VM.
Switching to Windows containers is as simple as right-clicking the Docker whale icon in the Windows notifications tray and selecting Switch to Windows containers...
. You can achieve the same thing from the command line with the following command (located in the \Program Files\Docker\Docker
directory):
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.
You’ll be prompted to enable the Windows Containers feature if it isn’t already enabled.
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 10 machine.
Installing Docker Desktop on Mac
Docker Desktop for Mac is like Docker Desktop on Windows 10 — a packaged product from Docker, Inc with a simple installer 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.
We’ll look at a simple installation in a second, but before doing that it’s worth noting that Docker Desktop on Mac doesn’t give you the Docker Engine running natively on the Mac OS Darwin kernel. Behind the scenes, the Docker daemon is running inside a lightweight Linux VM that seamlessly exposes the daemon and API to your Mac environment. This means you can open a terminal on your Mac and use the regular Docker commands.
Although this works seamlessly on your Mac, don’t forget that it’s Docker on Linux under the hood — so it’s only going work with Linux-based Docker containers. This is good though, as it’s 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 perform a google search for “install Docker Desktop”. Follow the links to the download page where you can download the installer and follow the instructions. It’s that simple.
As with Docker Desktop on Windows 10, you can choose the stable channel
or the edge channel
— the edge channel
providing earlier access bleeding-edge features.
Download the installer and follow the step-by-step instructions.
Once the installation is complete you may have to manually start Docker Desktop from the MacOS Launchpad. It can take a minute for it to start, and you can watch the animated Docker whale icon in the status bar at the top of your screen. Once Docker Desktop is started, the whale will stop being animated. 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
. This is because the daemon is running inside of the Linux VM we mentioned earlier. The Client component is a native Mac application and runs directly on the Mac OS Darwin kernel (OS/Arch: darwin/amd64
).
You can now use Docker on your Mac.
Installing Docker on Linux
There are lots of ways to install Docker on Linux and most of them are easy. The hardest part is usually deciding which Linux distro to use.
The internet has lots of guides for installing and working with Docker on many distributions of Linux. In this section we’ll look at one of the ways to install on Ubuntu Linux 20.04 LTS. The procedure assumes you’ve already installed Linux and are logged on.
- Update the apt package index.
- Install Docker from the official repo.
Docker is now installed and you can test by running some commands.
Installing Docker on Windows Server 2019
Most of the public cloud platforms offer off-the-shelf copies of Windows Server 2019 with Docker pre-installed. Simply choose one of these – such as Microsoft Windows Server 2019 Base with Containers - ami-0b809eef92577a4f1
on AWS – and you’re good to go.
Installing Docker on other versions of Windows Server 2019 is incredibly easy.
The following procedure assumes you’ve installed Windows Server 2019 and are logged on with administrator privileges.
- Install the Docker Provider
Run this command from a PowerShell terminal.
- Install Docker
- Restart your machine
Congratulations, Docker is now installed and configured to automatically start when the system boots.
Run some commands to verify Docker is working.
Docker is now installed and you are ready to start using Windows containers.
Play with Docker
Play with Docker (PWD) provides a free-to-use fully functional 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-to-use service it is 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 single-engine Docker environment on your Mac or Windows 10 laptop. It’s simple to install, is intended for development activities and even allows you to spin-up a single-node Kubernetes cluster.
Docker can be installed on Windows Server and Linux, with most operating systems having packages that are simple to install.
Play with Docker is a free 4-hour Docker playground on the internet.