CHAPTER 02
Beginner
Installing Docker on Windows, Linux, and macOS
Updated: May 15, 2026
15 min read
# CHAPTER 2
Installing Docker on Windows, Linux, and macOS
1. Introduction
Before we can begin packaging our applications into standardized containers, we must prepare our local development environment. Installing Docker used to be a highly complex process requiring deep Linux kernel knowledge. Today, Docker provides incredibly smooth installation packages for every major operating system. In this chapter, we will guide you through installing Docker Desktop for Windows and Mac, as well as the native Docker Engine for Linux, ensuring your system is ready for containerization.2. Learning Objectives
By the end of this chapter, you will be able to:- Understand the system requirements for running Docker.
- Install Docker Desktop on Windows (using WSL2).
- Install Docker Desktop on macOS (Intel and Apple Silicon).
- Install the native Docker Engine on a Linux distribution.
- Verify your installation using the Docker CLI.
3. Beginner-Friendly Explanation
Imagine installing a high-tech video game console.- Linux: Docker was built natively for Linux. Installing Docker on Linux is like plugging a PlayStation directly into a TV. It is native, direct, and highly efficient.
- Windows and Mac: Because Docker requires Linux features to run, Windows and Mac cannot run it natively. When you install "Docker Desktop" on a Mac or Windows PC, Docker secretly installs a tiny, invisible Linux machine in the background. It acts as an adapter, allowing your Mac/Windows computer to play Linux container "games" flawlessly.
4. Docker Desktop vs. Docker Engine
- Docker Desktop: A massive, all-in-one GUI (Graphical User Interface) application for Mac and Windows. It includes the Docker Daemon, the Docker CLI, Docker Compose, and a visual dashboard to click and view your containers.
- Docker Engine: The raw, command-line-only version of Docker, traditionally installed on Linux servers in production environments. It has no graphical interface.
5. Installing on Windows (The WSL2 Requirement)
To run Docker on Windows 10/11, your computer must use WSL2 (Windows Subsystem for Linux). This is a massive improvement over older virtualization methods.- 1. Download Docker Desktop for Windows from the official Docker website.
- 2. Run the installer. Ensure the box "Use WSL 2 instead of Hyper-V" is checked!
- 3. Restart your computer.
- 4. When Docker Desktop launches, it may prompt you to install a WSL2 kernel update from Microsoft. Follow the link provided, install the small update, and click Restart in Docker Desktop.
6. Installing on macOS
Docker supports both older Intel Macs and newer Apple Silicon (M1/M2/M3) Macs.- 1. Download Docker Desktop for Mac (Choose the correct chip version: Intel or Apple Silicon).
-
2.
Open the
.dmgfile and drag the Docker icon into your Applications folder.
- 3. Open Docker from your Applications. It will ask for permission to install networking components (requires your Mac password).
- 4. Look at the top menu bar of your Mac. You will see a small "Whale" icon. When the whale stops animating, Docker is running!
7. Installing on Linux (Ubuntu Example)
Linux does not need the heavy "Docker Desktop" GUI. You install the raw Engine via the terminal.
bash
8. Mini Project: Verify Your Docker Installation
Let's ensure the Docker Daemon is awake and communicating with your CLI.Step-by-Step Tutorial:
- 1. Open your Terminal (Mac/Linux) or PowerShell/Command Prompt (Windows).
- 2. Type the following command to check the version:
bash
*(You should see something like: Docker version 24.0.5, build ced3990)*
- 3. Now, let's run the universal Docker test:
bash
- 4. Docker will download a tiny test image, run it, print a welcoming message to your screen ("Hello from Docker!"), and immediately shut the container down. Your installation is perfect!
9. Real-World Scenarios
In the real world, developers use Docker Desktop on their local laptops to write and test code visually. However, when the code is deployed to the cloud (like an AWS EC2 instance), the DevOps engineer will install the raw, headless Linux Docker Engine to save RAM and CPU resources.10. Best Practices
-
Linux Post-Installation (The
sudoProblem): By default, on Linux, you must typesudo docker run...every single time. To fix this, you must add your user to thedockergroup. Run:sudo usermod -aG docker $USER. Then log out and log back in. You can now run Docker commands withoutsudo.
11. Common Mistakes
- Hardware Virtualization Disabled: On Windows, if Docker Desktop refuses to start and gives a "Virtualization must be enabled" error, you must restart your physical computer, enter your motherboard's BIOS settings, and turn on CPU Virtualization (Intel VT-x or AMD-V).
12. Exercises
- 1. What is the fundamental difference between Docker Desktop and the Docker Engine?
- 2. Why does Windows require WSL2 (Windows Subsystem for Linux) to run Docker efficiently?
13. FAQs
Q: Is Docker Desktop free? A: Docker Desktop is free for personal use, education, and small businesses. However, for large enterprise companies (more than 250 employees OR more than $10 million in revenue), Docker Desktop requires a paid subscription. (The raw Linux Docker Engine remains 100% free and open-source for everyone).14. Interview Questions
- Q: Explain how Docker achieves cross-platform compatibility. How can a container built for Linux run on a macOS laptop?
-
Q: Describe the purpose of the
hello-worldDocker image. What background processes occur when you executedocker run hello-worldfor the very first time?
15. Summary
In Chapter 2, we successfully prepared our local development environments. We navigated the installation nuances between Windows, macOS, and Linux. We established that Windows and Mac require the Docker Desktop GUI and a hidden Linux micro-VM, whereas Linux runs the raw Docker Engine natively. Finally, we executed our very first Docker command, verifying our installation with the universalhello-world test container.