How to Install Docker on Windows, Mac, and Linux: The Complete Guide test
Ready to start containerizing your applications? This comprehensive guide walks you through the step-by-step installation of Docker Desktop on Windows and macOS, and Docker Engine on popular Linux distributions like Ubuntu, Fedora, and CentOS. We cover system requirements, installation steps, and how to verify your setup on all platforms.
Here's a comprehensive guide to getting Docker up and running on your Windows, Mac, or Linux machine.
π Your Cross-Platform Guide to Installing Docker
Docker has revolutionized the way developers build, share, and run applications. By containerizing applications, it bundles all the code, libraries, and dependencies into a single package that can run reliably on any machine.
But before you can start containerizing, you need to install it. This guide will walk you through installing Docker on Windows, macOS, and the most common Linux distributions.
π₯οΈ Installing Docker on Windows
On Windows, you'll be installing Docker Desktop, a graphical application that includes the Docker Engine, CLI, and other tools. The modern version of Docker Desktop for Windows runs on the Windows Subsystem for Linux 2 (WSL 2), which provides a high-performance, fully integrated Linux kernel.
β System Requirements
- OS: Windows 10 (version 21H2 or newer) or Windows 11 (version 21H2 or newer). Home, Pro, Enterprise, or Education editions are supported.
- Hardware:
- 64-bit processor with Second Level Address Translation (SLAT).
- At least 4GB of RAM.
- Hardware virtualization must be enabled in your computer's BIOS/UEFI. This is often labeled as "Intel VT-x," "AMD-V," or similar.
- WSL 2: You must have the WSL 2 feature enabled. If you don't, the Docker Desktop installer will offer to enable it for you.
βοΈ Installation Steps
- Download Docker Desktop: Go to the official Docker website and download the "Docker Desktop for Windows" installer.
- Run the Installer: Double-click the downloaded
.exefile. - Enable WSL 2: Follow the on-screen prompts. The installer will ask you to ensure the "Use WSL 2 instead of Hyper-V" option is checked. This is the recommended and default setting. If WSL 2 is not already installed, the installer will guide you through the process, which may require a system restart.
- Complete Installation: Once the installation is finished, Docker Desktop will start automatically. The Docker whale icon π will appear in your system tray.
- Verify Installation: Open a terminal (like PowerShell or Command Prompt) and run the following commands.
- First, check the Docker version:
docker --version - Next, run the "hello-world" container to confirm everything is working:
docker run hello-world
- First, check the Docker version:
You should see a message that begins with "Hello from Docker!" This confirms that your installation is successful.
π Installing Docker on macOS
Similar to Windows, the installation for macOS is done using the Docker Desktop application. It provides a seamless experience, whether you're on an Intel-based Mac or a newer one with an Apple Silicon chip (M1, M2, M3, etc.).
β System Requirements
- OS: One of the three most recent major versions of macOS.
- Hardware:
- Apple Silicon (M1/M2/M3): You will need to install Rosetta 2 if you want to run Intel-based (amd64) containers. Docker Desktop will prompt you if it's needed.
- Intel Mac: A 2010 or newer model with Intel's hardware support for virtualization.
- RAM: At least 4GB of RAM.
βοΈ Installation Steps
- Download Docker Desktop: Go to the Docker website and download the correct installer for your Mac:
- Docker Desktop for Mac (Apple Silicon)
- Docker Desktop for Mac (Intel Chip)
- Run the Installer: Double-click the downloaded
.dmgfile. - Install Application: A window will pop up. Drag the Docker icon into your Applications folder.
- Launch Docker: Go to your Applications folder and double-click the Docker app to start it.
- Authorize Installation: You may be asked to authorize the installation with your system password.
- Verify Installation: Once the whale icon π appears in your top status bar, open your Terminal and run the same verification commands:
- Check the version:
docker --version - Run the "hello-world" container:
docker run hello-world
- Check the version:
Seeing the "Hello from Docker!" message means you're all set.
π§ Installing Docker on Linux
On Linux, you typically install the Docker Engine (the command-line backend) directly using your distribution's package manager. Docker Desktop is also available for Linux but is not the standard approach for most server or development work.
The recommended method is to install from Docker's official repository, which ensures you get the latest version.
π Post-Installation Step (Do This for All Linux Distros!)
By default, Docker commands require sudo (root) privileges. To run docker commands as a non-root user, you must add your user to the docker group.
- Create the
dockergroup (it may already exist):sudo groupadd docker - Add your user to the
dockergroup:sudo usermod -aG docker $USER - Log Out and Log Back In: For the new group membership to take effect, you must log out of your session completely and log back in.
- After logging back in, test that it worked by running
docker run hello-worldwithoutsudo.
Ubuntu / Debian
- Update and Install Prerequisites:
sudo apt-get update sudo apt-get install ca-certificates curl - Add Dockerβs Official GPG Key:
sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL [https://download.docker.com/linux/ubuntu/gpg](https://download.docker.com/linux/ubuntu/gpg) -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc - Set Up the Repository:
(For Debian, replaceecho \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] [https://download.docker.com/linux/ubuntu](https://download.docker.com/linux/ubuntu) \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullubuntuwithdebianin the URL) - Install Docker Engine:
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - Verify and run the post-installation step (above).
Fedora
- Set Up the Repository:
sudo dnf -y install dnf-plugins-core sudo dnf config-manager --add-repo [https://download.docker.com/linux/fedora/docker-ce.repo](https://download.docker.com/linux/fedora/docker-ce.repo) - Install Docker Engine:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - Start and Enable Docker Service:
sudo systemctl start docker sudo systemctl enable docker - Verify and run the post-installation step (above).
CentOS
Note: CentOS 8 has been replaced by CentOS Stream. These instructions are for CentOS Stream or RHEL-based distros like Rocky Linux or AlmaLinux.
- Set Up the Repository:
sudo dnf -y install dnf-plugins-core sudo dnf config-manager --add-repo [https://download.docker.com/linux/centos/docker-ce.repo](https://download.docker.com/linux/centos/docker-ce.repo) - Install Docker Engine:
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - Start and Enable Docker Service:
sudo systemctl start docker sudo systemctl enable docker - Verify and run the post-installation step (above).
Comments (0)
Comment system coming soon...