Module 2 Lesson 2: Installing Docker
Get your environment ready. Step-by-step instructions for installing Docker Desktop on Windows and Mac, and Docker Engine on Linux.
Module 2 Lesson 2: Installing Docker
Before we can run containers, we need the engine. This lesson covers the installation path for the three major operating systems.
1. Windows: Docker Desktop
Docker Desktop is the recommended way to run Docker on Windows. It uses WSL 2 (Windows Subsystem for Linux) for the best performance.
- Prerequisites: Windows 10/11 (Pro, Enterprise, or Home) with WSL 2 enabled.
- Steps:
- Download the "Docker Desktop for Windows" installer from docker.com.
- Run the installer. Ensure the "Use WSL 2 instead of Hyper-V" option is checked.
- Restart your computer.
- Open the Docker Desktop app. Wait for the whale icon in the taskbar to stay still.
2. Mac: Docker Desktop
Docker Desktop for Mac provides a seamless experience for both Intel and Apple Silicon (M1/M2/M3) chips.
- Prerequisites: macOS version 11 or newer.
- Steps:
- Download the correct installer (Intel vs. Apple Chip) from docker.com.
- Double-click the
.dmgand drag the Docker icon to yourApplicationsfolder. - Launch Docker from your Applications.
- Grant the necessary permissions for networking and privileged access.
3. Linux (Ubuntu Example)
On Linux, we usually install the Docker Engine (no GUI) directly.
- Steps:
- Update your packages:
sudo apt-get update. - Install prerequisites:
sudo apt-get install ca-certificates curl gnupg. - Add Docker’s official GPG key and repository.
- Install the engine:
sudo apt-get install docker-ce docker-ce-cli containerd.io.
- Update your packages:
- Post-Install (Crucial): By default, you have to run
sudo docker. To run withoutsudo, add your user to the docker group:
(Log out and log back in for this to take effect).sudo usermod -aG docker $USER
4. Verifying the Installation
Open your terminal (Command Prompt, PowerShell, or Terminal) and run:
docker --version
Then, try the most famous first command:
docker run hello-world
If you see: "Hello from Docker! This message shows that your installation appears to be working correctly," you are ready!
Troubleshooting Common Issues
- "Docker daemon not running": On Windows/Mac, make sure the Docker Desktop app is actually open.
- "WSL 2 installation is incomplete": Follow the link provided in the Docker error message to update the Linux kernel component from Microsoft.
- "Permission Denied": On Linux, make sure you performed the
usermodstep above.
Exercise: System Check
- Run
docker infoin your terminal. Look for the "Operating System" and "Kernel Version" entries. What do they say? - If you are on Windows/Mac, check the Docker Desktop settings. How many CPUs and how much RAM is Docker allowed to use by default?
- Why is it better to use WSL 2 on Windows instead of the older "Hyper-V" backend? (Search for "Docker WSL2 benefits").
Summary
You now have a working Docker environment. Whether you chose the GUI-friendly Desktop version or the raw Linux Engine, the core commands we learn next will work exactly the same way.
Next Lesson: We master the command line: Core Docker CLI commands.