Skip to content

Docker - Installation

This chapter guides you through installing Docker on various operating systems. We’ll cover the modern methods for Windows, macOS, and Linux.

For Windows 10/11 and recent macOS versions, Docker Desktop is the recommended installation. It provides a seamless experience, including the Docker Engine, CLI tools, Kubernetes integration, and a graphical user interface.

  • Windows: Windows 10 64-bit (Pro, Enterprise, or Education) or Windows 11 64-bit. WSL 2 (Windows Subsystem for Linux version 2) backend enabled is highly recommended (often handled by the installer). Virtualization must be enabled in BIOS.
  • macOS: Check the Docker Desktop documentation for the minimum supported macOS version. Virtualization capabilities are required.
  1. Download the Docker Desktop installer from the official Docker website: https://www.docker.com/products/docker-desktop/
  2. Double-click the downloaded installer file.
  3. Follow the on-screen instructions. The installer typically handles necessary configurations, including enabling WSL 2 features on Windows if needed.
  4. Once installed, launch Docker Desktop. You might need to log in with your Docker Hub account for certain features.

On Linux, you typically install the Docker Engine components directly. The most common method involves setting up Docker’s official repository.

  • A supported Linux distribution (e.g., Ubuntu, Debian, Fedora, CentOS). Check Docker’s documentation for specific supported versions.
  • 64-bit architecture.
  • Kernel version 3.10 or higher (most modern distributions meet this).

Note: Commands might require sudo privileges.

  1. Update package index and install prerequisite packages:
Terminal window
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
  1. Add Docker’s official GPG key:
Terminal window
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  1. Set up the repository:
Terminal window
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  1. Install Docker Engine:
Terminal window
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
  1. Post-installation steps (Optional but recommended): Add your user to the docker group to run Docker commands without sudo:
Terminal window
sudo usermod -aG docker $USER

(You’ll need to log out and back in, or run newgrp docker for this change to take effect in your current session.)

Docker provides a convenience script for quick installation, suitable for development environments. Use with caution in production:

Terminal window
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

After installation, verify Docker is running correctly by executing the hello-world container:

docker run hello-world

This command downloads a minimal test image and runs it in a container. If successful, it prints a confirmation message indicating your Docker installation is working.

For more detailed information about your Docker setup:

docker version
docker info