[Docker Basics] Step-by-Step Guide to Installing Docker on Windows, macOS, and Linux

Docker is the key to packaging, distributing, and running applications consistently across any environment. Whether you are an experienced developer or a complete beginner, installing Docker is the first and most important step.

Step-by-step guide to installing Docker on Windows, macOS, and Linux

This article provides a step-by-step guide to installing Docker Desktop on Windows and macOS, and Docker Engine on the most popular Linux distributions (Ubuntu, CentOS, Debian). Let’s start your journey to mastering container technology now! 🚀

🐳 Installing Docker on Windows: Simple and Intuitive

For Docker Desktop, Windows users get a friendly graphical interface and deep system integration, especially the choice between WSL 2 (Windows Subsystem for Linux 2) and Hyper-V as the backend.

System Requirements

Before you begin, make sure your computer meets the following requirements:

  • Operating System: Windows 10 64-bit (version 1903 or later) or Windows 11 64-bit.
  • WSL 2: Must be enabled. This is the recommended method for best performance.
  • CPU: Hardware virtualization support (Virtualization) must be enabled in BIOS.
  • RAM: At least 4 GB.

Installation Steps

  1. Enable WSL 2 and Virtual Machine Platform: Open PowerShell as Administrator and run the following commands:

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    

    After running these commands, restart your computer.

  2. Download Docker Desktop: Go to the official Docker website to download the latest installer for Windows.

    ➡️ Download Docker Desktop for Windows

  3. Run the installer: Open the .exe file you just downloaded. The installation process is straightforward—just follow the on-screen instructions. Make sure the option "Use WSL 2 instead of Hyper-V" is selected.

  4. Finish and restart: After installation, Docker Desktop may ask you to restart your computer again.

  5. Verify installation: When Docker Desktop is running (the whale 🐳 icon appears in the system tray), open Command Prompt or PowerShell and type:

    docker --version
    

    If you see the Docker version information, congratulations—you’ve installed Docker successfully!

🍏 Installing Docker on macOS: Seamless Integration

Like Windows, Docker Desktop on macOS offers a smooth experience and deep OS integration, leveraging Apple’s HyperKit virtualization framework.

System Requirements

  • macOS: Version 10.15 (Catalina) or later.
  • Chip: Supports both Intel and Apple Silicon (M1, M2, etc.).
  • RAM: At least 4 GB.

Installation Steps

  1. Download Docker Desktop: Visit the official Docker website and choose the version that matches your Mac’s chip (Intel or Apple Silicon).

    ➡️ Download Docker Desktop for macOS

  2. Run the installer: Open the Docker.dmg file you downloaded. Drag and drop the Docker icon into your Applications folder.

  3. Launch Docker: Open Docker from the Applications folder. The first time you run it, Docker will request access and perform some initial setup.

  4. Verify installation: Once the Docker 🐳 icon appears in the menu bar and is "running", open the Terminal app and type:

    docker run hello-world
    

    This command downloads a small image and runs a simple container. If you see the message "Hello from Docker!", you’ve installed Docker successfully.

🐧 Docker Engine for Linux: Power and Flexibility

On Linux, we’ll install Docker Engine, the powerful command-line version and the backbone of Docker. Here are detailed instructions for the most popular distributions.

1. Ubuntu

Installing Docker on Ubuntu via the official repository is recommended to ensure you always get the latest updates.

  1. Remove old versions (if any):

    sudo apt-get remove docker docker-engine docker.io containerd runc
    
  2. Set up the repository:

    sudo apt-get update
    sudo apt-get install -y ca-certificates curl gnupg lsb-release
    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    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
    
  3. Install Docker Engine:

    sudo apt-get update
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    
  4. Configure Docker to run without sudo (recommended): Add your current user to the docker group:

    sudo groupadd docker
    sudo usermod -aG docker $USER
    

    Note: You need to log out and log back in or restart your computer for this change to take effect.

  5. Verify installation:

    docker run hello-world
    

2. CentOS

Like Ubuntu, we’ll use Docker’s official repository.

  1. Remove old versions (if any):

    sudo yum remove docker \
                      docker-client \
                      docker-client-latest \
                      docker-common \
                      docker-latest \
                      docker-latest-logrotate \
                      docker-logrotate \
                      docker-engine
    
  2. Set up the repository:

    sudo yum install -y yum-utils
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    
  3. Install Docker Engine:

    sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    
  4. Start Docker:

    sudo systemctl start docker
    sudo systemctl enable docker  # Start Docker automatically on boot
    
  5. Configure Docker to run without sudo (recommended):

    sudo groupadd docker
    sudo usermod -aG docker $USER
    

    Note: Log out and log back in to apply the change.

  6. Verify installation:

    docker run hello-world
    

3. Debian

The steps for Debian are very similar to Ubuntu.

  1. Remove old versions:

    sudo apt-get remove docker docker-engine docker.io containerd runc
    
  2. Set up the repository:

    sudo apt-get update
    sudo apt-get install -y ca-certificates curl gnupg lsb-release
    sudo mkdir -p /etc/apt/keyrings
    curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    
  3. Install Docker Engine:

    sudo apt-get update
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    
  4. Configure Docker to run without sudo and verify: Do the same as on Ubuntu.

Conclusion: Installing Docker is No Longer a Barrier

With this detailed guide, installing Docker is no longer a barrier. From now on, you have the most powerful containerization tool at your disposal, ready to deploy your applications efficiently and professionally.

Your Docker journey is just beginning. Explore Docker Hub, learn to write Dockerfiles, and master Docker Compose to take your projects to the next level. Good luck!

Related Posts

[Docker Basics] Image and Container: Concepts, Differences, and Usage

A detailed look at Docker Images and Containers. This article will help you understand the concepts, differences, and how to use these two core components of Docker effectively.

[Docker Basics] A Simple and Effective Guide to Building Docker Images

Want to build Docker Images like a pro? This article provides a step-by-step guide, from basic Dockerfiles to optimization tips for creating lightweight and efficient Docker Images.

[Docker Basics] Essential Commands to Run Docker Containers

Learn the basic Docker commands to run containers effectively. This article guides you step-by-step through using docker run, docker ps, and other important options.

[Docker Basics] How to Write an Optimal Dockerfile for Beginners

A detailed guide to writing effective Dockerfiles for beginners. Learn key instructions, tips for optimizing image size, and how to build production-ready images.