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.

S
Shubham Sharma
1 day ago
❀️ 0 likesπŸ’¬ 0 comments
How to Install Docker on Windows, Mac, and Linux: The Complete Guide test

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

  1. Download Docker Desktop: Go to the official Docker website and download the "Docker Desktop for Windows" installer.
  2. Run the Installer: Double-click the downloaded .exe file.
  3. 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.
  4. Complete Installation: Once the installation is finished, Docker Desktop will start automatically. The Docker whale icon πŸ‹ will appear in your system tray.
  5. 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
      

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

  1. 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)
  2. Run the Installer: Double-click the downloaded .dmg file.
  3. Install Application: A window will pop up. Drag the Docker icon into your Applications folder.
  4. Launch Docker: Go to your Applications folder and double-click the Docker app to start it.
  5. Authorize Installation: You may be asked to authorize the installation with your system password.
  6. 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
      

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.

  1. Create the docker group (it may already exist):
    sudo groupadd docker
    
  2. Add your user to the docker group:
    sudo usermod -aG docker $USER
    
  3. 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.
  4. After logging back in, test that it worked by running docker run hello-world without sudo.

Ubuntu / Debian

  1. Update and Install Prerequisites:
    sudo apt-get update
    sudo apt-get install ca-certificates curl
    
  2. 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
    
  3. Set Up the Repository:
    echo \
      "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/null
    
    (For Debian, replace ubuntu with debian in the URL)
  4. Install Docker Engine:
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
  5. Verify and run the post-installation step (above).

Fedora

  1. 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)
    
  2. Install Docker Engine:
    sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
  3. Start and Enable Docker Service:
    sudo systemctl start docker
    sudo systemctl enable docker
    
  4. 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.

  1. 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)
    
  2. Install Docker Engine:
    sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
  3. Start and Enable Docker Service:
    sudo systemctl start docker
    sudo systemctl enable docker
    
  4. Verify and run the post-installation step (above).

Comments (0)

Comment system coming soon...