How to Install Docker

Introduction Docker has revolutionized the way developers build, ship, and run applications. It is a platform that automates the deployment of applications inside lightweight, portable containers. Installing Docker correctly is a critical first step for anyone looking to leverage containerization technology for development, testing, or production environments. This tutorial provides a comprehensiv

Nov 17, 2025 - 10:53
Nov 17, 2025 - 10:53
 3

Introduction

Docker has revolutionized the way developers build, ship, and run applications. It is a platform that automates the deployment of applications inside lightweight, portable containers. Installing Docker correctly is a critical first step for anyone looking to leverage containerization technology for development, testing, or production environments. This tutorial provides a comprehensive, step-by-step guide on how to install Docker across different operating systems, ensuring you have a solid foundation to begin your container journey.

Understanding how to install Docker not only empowers developers to streamline workflows but also enables system administrators to manage infrastructure more efficiently. Whether you are a beginner or an experienced professional, mastering Docker installation is essential for modern software development and DevOps practices.

Step-by-Step Guide

1. Prerequisites

Before installing Docker, ensure your system meets the minimum requirements:

  • Operating System: Supported versions of Linux (Ubuntu, CentOS, Debian), Windows 10/11 (Professional or Enterprise), or macOS.
  • Hardware: 64-bit processor with virtualization support enabled in BIOS/UEFI.
  • Permissions: Administrative or root access to install software.
  • Internet connection: Required to download Docker installation packages.

2. Installing Docker on Ubuntu

Ubuntu is one of the most popular Linux distributions for Docker. Follow these steps to install Docker on Ubuntu:

  1. Update your existing list of packages:

    sudo apt-get update

  2. Install prerequisite packages:

    These packages allow apt to use repositories over HTTPS.

    sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

  3. Add Dockers official GPG key:

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

  4. Set up the stable Docker repository:

    echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

  5. Update the package database again:

    sudo apt-get update

  6. Install Docker Engine:

    sudo apt-get install docker-ce docker-ce-cli containerd.io

  7. Verify Docker installation:

    sudo docker run hello-world

    This command downloads a test image and runs it in a container. If it runs successfully, Docker is installed correctly.

3. Installing Docker on CentOS

  1. Remove older versions:

    sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

  2. Set up the Docker 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 docker-ce docker-ce-cli containerd.io

  4. Start Docker service:

    sudo systemctl start docker

  5. Enable Docker to start on boot:

    sudo systemctl enable docker

  6. Verify installation:

    sudo docker run hello-world

4. Installing Docker on Windows 10/11

Docker Desktop for Windows provides an easy-to-install application that includes Docker Engine and Docker CLI. Follow these steps:

  1. Check system requirements: Windows 10 Pro, Enterprise, or Education (64-bit) with Hyper-V and Containers features enabled.
  2. Download Docker Desktop: Visit the official Docker website and download the latest installer.
  3. Run the installer: Follow the installation wizard. During installation, enable the option to use WSL 2 backend if desired.
  4. Restart your machine: Some changes require rebooting.
  5. Launch Docker Desktop: After reboot, open Docker Desktop. It will initialize and start the Docker daemon.
  6. Verify installation: Open PowerShell or Command Prompt and run docker run hello-world.

5. Installing Docker on macOS

  1. Download Docker Desktop for Mac: Access the official Docker website and download the installer.
  2. Install Docker: Open the downloaded .dmg file and drag the Docker icon to the Applications folder.
  3. Launch Docker: Open Docker from Applications. It may request privileged access to install networking components.
  4. Verify installation: Open Terminal and run docker run hello-world.

6. Post-Installation Steps

To avoid using sudo with Docker commands on Linux:

  1. Add your user to the Docker group:
  2. sudo usermod -aG docker $USER

  3. Log out and log back in to apply the group changes.
  4. Verify by running docker run hello-world without sudo.

Best Practices

1. Keep Docker Updated

Regularly update Docker to the latest stable version to benefit from security patches, new features, and performance improvements.

2. Use Official Repositories

Always use Dockers official repositories or trusted sources for installation files to ensure authenticity and security.

3. Enable Docker Daemon Security

Configure Docker daemon to run securely with proper user permissions and avoid running containers as root unless necessary.

4. Manage Docker Resources

Set resource limits for containers (CPU, memory) to prevent overconsumption and maintain system stability.

5. Automate Installation for Teams

Use configuration management tools like Ansible, Puppet, or scripts to standardize Docker installation across multiple machines.

6. Backup Docker Data

Regularly backup Docker volumes, images, and configuration files to prevent data loss.

Tools and Resources

1. Official Docker Documentation

The best source for up-to-date installation instructions and Docker features.

https://docs.docker.com/get-docker/

2. Docker Hub

A repository of container images for various applications and services.

https://hub.docker.com/

3. Docker Compose

A tool to define and run multi-container Docker applications.

https://docs.docker.com/compose/

4. Community Forums and GitHub

Engage with the Docker community for support, troubleshooting, and best practices.

https://forums.docker.com/

Real Examples

Example 1: Installing Docker on Ubuntu 22.04

Scenario: A developer wants to set up Docker on a fresh Ubuntu 22.04 server to deploy containerized applications.

Steps Taken:

  1. Updated packages with sudo apt-get update.
  2. Installed prerequisites.
  3. Added Docker's GPG key and repository.
  4. Installed Docker Engine.
  5. Verified installation by running sudo docker run hello-world.

Outcome: Docker installed successfully, ready to use.

Example 2: Setting up Docker Desktop on Windows 11

Scenario: A team lead wants to enable Windows 11 developers to use Docker Desktop for local container development.

Steps Taken:

  1. Downloaded Docker Desktop installer from the official site.
  2. Installed and enabled WSL 2 backend.
  3. Restarted machines.
  4. Verified installation with docker run hello-world.

Outcome: Developers can now build and run containers natively on Windows.

Example 3: Using Docker on macOS for Local Development

Scenario: A macOS user wants to install Docker to create local development environments.

Steps Taken:

  1. Downloaded Docker Desktop for Mac.
  2. Installed and started the application.
  3. Ran docker run hello-world successfully.

Outcome: Docker environment ready for containerized app development.

FAQs

Q1: What versions of operating systems does Docker support?

Docker supports most modern 64-bit versions of Linux distributions (Ubuntu, CentOS, Debian), Windows 10/11 Professional, Enterprise, or Education editions, and macOS Mojave or newer.

Q2: Can I install Docker on Windows Home edition?

Yes, but you need to use Docker Desktop with WSL 2 backend enabled. Windows Home does not support Hyper-V, which is used by Docker Desktop on other Windows editions.

Q3: Is Docker free to use?

Docker Engine and Docker Desktop have free tiers for individual and small business use. Larger organizations may require paid subscriptions for additional features.

Q4: How do I uninstall Docker?

Uninstallation procedures vary by operating system. Typically, use package managers on Linux (apt-get remove or yum remove) or uninstall via Control Panel on Windows and drag to Trash on macOS.

Q5: How do I keep Docker updated?

Use your systems package manager to update Docker on Linux. For Docker Desktop, check for updates within the application or download the latest installer from the official website.

Conclusion

Installing Docker is a foundational skill for modern developers, system administrators, and DevOps engineers. This tutorial has provided detailed instructions for installing Docker on various platforms, highlighting best practices and useful resources to ensure a smooth setup process. By following these steps and leveraging Dockers powerful containerization capabilities, you can significantly improve your development workflow, application deployment, and infrastructure management.

Remember to keep Docker updated, secure your environment, and explore Dockers vast ecosystem to maximize productivity and efficiency. Start your Docker journey today and unlock the potential of containerized applications.