Docker - Installation
Docker - Installation
Section titled “Docker - Installation”This chapter guides you through installing Docker on various operating systems. We’ll cover the modern methods for Windows, macOS, and Linux.
Docker Desktop (Windows and macOS)
Section titled “Docker Desktop (Windows and macOS)”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.
Prerequisites:
Section titled “Prerequisites:”- 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.
Installation Steps:
Section titled “Installation Steps:”- Download the Docker Desktop installer from the official Docker website: https://www.docker.com/products/docker-desktop/
- Double-click the downloaded installer file.
- Follow the on-screen instructions. The installer typically handles necessary configurations, including enabling WSL 2 features on Windows if needed.
- Once installed, launch Docker Desktop. You might need to log in with your Docker Hub account for certain features.
Docker Engine (Linux)
Section titled “Docker Engine (Linux)”On Linux, you typically install the Docker Engine components directly. The most common method involves setting up Docker’s official repository.
Prerequisites:
Section titled “Prerequisites:”- 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).
Installation Steps (Example for Ubuntu):
Section titled “Installation Steps (Example for Ubuntu):”Note: Commands might require sudo privileges.
- Update package index and install prerequisite packages:
sudo apt-get updatesudo apt-get install ca-certificates curl gnupg lsb-release- Add Docker’s official GPG key:
sudo mkdir -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg- Set up the repository:
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- Install Docker Engine:
sudo apt-get updatesudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y- Post-installation steps (Optional but recommended): Add your user to the
dockergroup to run Docker commands withoutsudo:
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.)
Alternative: Convenience Script
Section titled “Alternative: Convenience Script”Docker provides a convenience script for quick installation, suitable for development environments. Use with caution in production:
curl -fsSL https://get.docker.com -o get-docker.shsudo sh get-docker.shVerify Installation
Section titled “Verify Installation”After installation, verify Docker is running correctly by executing the hello-world container:
docker run hello-worldThis 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 versiondocker info