Installing Docker Desktop on macOS or Windows
If you are using macOS or have Windows 10 or later installed on your laptop, then we strongly recommend that you install Docker Desktop. Since early 2022, Docker has also released a version of Docker Desktop for Linux. Docker Desktop gives you the best experience when working with containers. Follow these steps to install Docker Desktop for your system:
- No matter what OS you’re using, navigate to the Docker start page at https://www.docker.com/get-started:
Figure 2.1 – Get Started with Docker
- On the right-hand side of the view, you will find a blue Sign up button for Docker Hub. Click this button if you don’t have an account on Docker Hub yet, then create one. It is free, but you need an account to download the software.
- On the left-hand side of the view, you will find a blue button called Download for <your OS>, where <your OS> can be Linux, Mac, or Windows, depending on which OS you are working with. In the authors’ case, it shows Mac as the target OS, but it got the CPU type wrong since the author is using a Mac with Apple’s M1 chip.
Click the small drop-down triangle on the right-hand side of the button to get the full list of available downloads:
Figure 2.2 – List of Docker Desktop targets
Select the one that is appropriate for you and observe the installation package being downloaded.
- Once the package has been completely downloaded, proceed with the installation, usually by double-clicking on the download package.
Testing Docker Engine
Now that you have successfully installed Docker Desktop, let’s test it. We will start by running a simple Docker container directly from the command line:
- Open a Terminal window and execute the following command:
$ docker version
You should see something like this:
Figure 2.3 – Docker version of Docker Desktop
In the preceding output, we can see that it consists of two parts – a client and a server. Here, the server corresponds to Docker Engine, which is responsible for hosting and running containers. At the time of writing, the version of Docker Engine is 20.10.21
.
- To see whether you can run containers, enter the following command into the Terminal window and hit Enter:
$ docker container run hello-world
If all goes well, your output should look something like the following:
Figure 2.4 – Running Hello-World on Docker Desktop for macOS
If you read the preceding output carefully, you will have noticed that Docker didn’t find an image called hello-world:latest
and thus decided to download it from a Docker image registry. Once downloaded, Docker Engine created a container from the image and ran it. The application runs inside the container and then outputs all the text, starting with Hello
from Docker!
.
This is proof that Docker is installed and working correctly on your machine.
- Let’s try another funny test image that’s usually used to check the Docker installation. Run the following command:
$ docker container run rancher/cowsay Hello
You should see this or a similar output:
Figure 2.5 – Running the cowsay image from Rancher
Great – we have confirmed that Docker Engine works on our local computer. Now, let’s make sure the same is true for Docker Desktop.
Testing Docker Desktop
Depending on the operating system you are working with, be it Linux, Mac, or Windows, you can access the context menu for Docker Desktop in different areas. In any case, the symbol you are looking for is the little whale carrying containers. Here is the symbol as found on a Mac – :
- Mac: You’ll find the icon on the right-hand side of your menu bar at the top of the screen.
- Windows: You’ll find the icon in the Windows system tray.
- Linux: Here are the instructions for Ubuntu. On your distro, it may be different. To start Docker Desktop for Linux, search for
Docker Desktop
via the Applications menu and open it. This will launch the Docker menu icon and open the Docker dashboard, reporting the status of Docker Desktop.
Once you have located the context menu for Docker Desktop on your computer, proceed with the following steps:
- Click the whale icon to display the context menu of Docker Desktop. On the authors’ Mac, it looks like this:
Figure 2.6 – Context menu for Docker Desktop
- From the menu, select Dashboard. The dashboard of Docker Desktop will open:
Figure 2.7 – Dashboard of Docker Desktop
We can see that the dashboard has multiple tabs, indicated on the left-hand side of the view. Currently, the Containers tab is active. Consequently, we can see the list of containers found in our system. Currently, on the author’s system, two have been found. If you inspect this carefully, you will see that these are the containers that we previously created from the hello-world
and rancher/cowsay
Docker images. They both have a status of Exited.
Please take some time and explore this dashboard a bit. Don’t worry if you get lost. It will all become much clearer as we proceed through the various chapters of this book.
- When you’re done exploring, close the dashboard window.
Note
Closing the dashboard will not stop Docker Desktop. The application, as well as Docker Engine, will continue to run in the background. If for some reason you want to stop Docker on your system completely, you can select Quit Docker Desktop from the context menu shown in Step 1.
Congratulations, you have successfully installed and tested Docker Desktop on your working computer! Now, let’s continue with a few other useful tools.