Introduction
In our last lesson, we explored Docker's client-server architecture, establishing how the docker client, the dockerd daemon, and a registry work together. You now have a solid theoretical foundation for what happens when you execute a Docker command.
Today, we transition from theory to practice. The goal is to set up your own Docker development environment. This lesson will guide you through installing Docker Desktop on your machine and verifying that it is running correctly. By the end, you'll have a fully functional Docker setup, ready for you to start running containers and building images, which is exactly the hands-on work you're aiming for.
Installing Docker Desktop
The most straightforward way to get started with Docker on a personal computer is by installing Docker Desktop. It's an all-in-one application that bundles the Docker daemon (dockerd), the Docker client (docker CLI), and other tools like Docker Compose, all managed through a convenient graphical user interface.
The official Docker website is the best source for the installation package.
This is the official download page for Docker Desktop. It provides the necessary installers and links to detailed installation instructions for all major operating systems.
On the page, find the section corresponding to your operating system: Mac, Windows, or Linux. Click on the "Install instructions" link for your OS and follow the steps provided there to download and run the installer. We will address some OS-specific details next.
Important Considerations for Your Operating System
While the official instructions are comprehensive, there are a few key points to be aware of, especially for Windows and Linux users.
For Windows Users:
Docker Desktop on Windows relies on the Windows Subsystem for Linux (WSL) to run Linux containers. The Docker installer typically handles this for you, but it's crucial to ensure it's set up correctly. The following guide from a Brown University CS course provides an excellent, detailed walkthrough of the WSL setup process.
[PDF] Setup Guide.docx - Brown CS
This guide offers very clear, step-by-step instructions for ensuring WSL is properly configured for Docker.
If you are on Windows, please read the section Windows Only: Install WSL. This will guide you through checking your current WSL setup and installing a Linux distribution if needed. After that, pay close attention to the short paragraph on connecting Docker with WSL, which shows how to enable the integration in the Docker Desktop settings. This is a critical step.
For Linux Users:
The installation process on Linux involves a few more command-line steps than on Mac or Windows. The official instructions linked from the Docker Desktop page are your primary guide. For a visual walkthrough, especially if you are using Ubuntu, this video can be a helpful companion to the text-based instructions.
How to Correctly Install Docker Desktop on Linux Ubuntu - Step-by-step Guide and Tutorial
This video by Aleksandar Haber provides a clear, step-by-step tutorial for installing Docker Desktop on Ubuntu.
You can follow along with this video as you work through the official installation documentation. It covers downloading the .deb package and running the necessary terminal commands to get Docker Desktop up and running.
For Mac Users:
The installation on macOS is typically the most straightforward. You download a .dmg file, drag the Docker application to your Applications folder, and run it. The setup guide from Brown CS offers a useful tip: do not use Homebrew to install Docker Desktop, as it may lead to versioning issues.
Verifying the Installation
Once the installation is complete and you have started the Docker Desktop application, the Docker daemon should be running in the background. Now, you need to verify that your Docker client (the command-line interface) can communicate with the daemon.
You will do this using two fundamental commands: docker version and docker info.
docker version: This command queries the Docker daemon and displays version information for both the client and the server. Seeing both sections in the output confirms that the client successfully connected to the daemon.docker info: This command returns detailed, system-wide information about your Docker installation, such as the number of running containers and local images, the storage driver in use, and details about the host operating system. A successful output here is definitive proof that the daemon is running and healthy.
The following short video shows the docker version command in action.
The Only Docker Tutorial You Need To Get Started
Watch this very brief clip to see the expected output of the version check command.
The segment from check if you have Docker shows exactly what to type and what a successful output looks like.
Now, let's perform the verification on your machine. The same Brown CS guide we used for the WSL setup has a perfect section on verification, including troubleshooting a common error.
[PDF] Setup Guide.docx - Brown CS
This guide provides concise instructions for using docker version and docker info to verify your installation.
Open your terminal (or PowerShell/Command Prompt on Windows) and follow the instructions under the heading Verify Docker Installation. Run both docker --version (or docker version) and docker info. If you see an error message like Cannot connect to the Docker daemon, the guide provides the most common reason: Docker Desktop isn't running. Make sure the application is open and has finished starting up.
If both commands execute without errors, your Docker environment is ready.
Conclusion
Congratulations on completing this essential setup! You have now installed Docker Desktop and, more importantly, verified that the Docker client and daemon are communicating correctly. Your machine is now a fully-fledged environment for container development.
Key Takeaways:
- Docker Desktop is the recommended all-in-one package for installing Docker on Mac, Windows, and Linux.
- On Windows, Docker Desktop depends on the Windows Subsystem for Linux (WSL), and ensuring its proper configuration is key.
- The
docker versioncommand confirms that the client and server (daemon) can communicate. - The
docker infocommand provides a comprehensive status of the Docker daemon, confirming it is running correctly.
You have now built your "workshop." In the next lesson, we will put it to immediate use by performing the quintessential first Docker action: running a container from a public image using docker run.