Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Ultimate Docker Container Book

You're reading from   The Ultimate Docker Container Book Build, test, ship, and run containers with Docker and Kubernetes

Arrow left icon
Product type Paperback
Published in Aug 2023
Publisher Packt
ISBN-13 9781804613986
Length 626 pages
Edition 3rd Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Dr. Gabriel N. Schenker Dr. Gabriel N. Schenker
Author Profile Icon Dr. Gabriel N. Schenker
Dr. Gabriel N. Schenker
Arrow right icon
View More author details
Toc

Table of Contents (26) Chapters Close

Preface 1. Part 1:Introduction
2. Chapter 1: What Are Containers and Why Should I Use Them? FREE CHAPTER 3. Chapter 2: Setting Up a Working Environment 4. Part 2:Containerization Fundamentals
5. Chapter 3: Mastering Containers 6. Chapter 4: Creating and Managing Container Images 7. Chapter 5: Data Volumes and Configuration 8. Chapter 6: Debugging Code Running in Containers 9. Chapter 7: Testing Applications Running in Containers 10. Chapter 8: Increasing Productivity with Docker Tips and Tricks 11. Part 3:Orchestration Fundamentals
12. Chapter 9: Learning about Distributed Application Architecture 13. Chapter 10: Using Single-Host Networking 14. Chapter 11: Managing Containers with Docker Compose 15. Chapter 12: Shipping Logs and Monitoring Containers 16. Chapter 13: Introducing Container Orchestration 17. Chapter 14: Introducing Docker Swarm 18. Chapter 15: Deploying and Running a Distributed Application on Docker Swarm 19. Part 4:Docker, Kubernetes, and the Cloud
20. Chapter 16: Introducing Kubernetes 21. Chapter 17: Deploying, Updating, and Securing an Application with Kubernetes 22. Chapter 18: Running a Containerized Application in the Cloud 23. Chapter 19: Monitoring and Troubleshooting an Application Running in Production 24. Index 25. Other Books You May Enjoy

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:

  1. 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

Figure 2.1 – Get Started with Docker

  1. 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.
  2. 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

Figure 2.2 – List of Docker Desktop targets

Select the one that is appropriate for you and observe the installation package being downloaded.

  1. 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:

  1. 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

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.

  1. 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

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.

  1. 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

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:

  1. 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

Figure 2.6 – Context menu for Docker Desktop

  1. From the menu, select Dashboard. The dashboard of Docker Desktop will open:
Figure 2.7 – Dashboard of Docker Desktop

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.

  1. 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.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image