How to Install Docker

Introduction Docker has become the de facto standard for containerization, enabling developers to package applications and their dependencies into lightweight, portable containers. Its ability to streamline deployment, improve consistency across environments, and accelerate development cycles has made it indispensable in modern software workflows. However, installing Docker incorrectly can lead to

Oct 25, 2025 - 12:21
Oct 25, 2025 - 12:21
 0

Introduction

Docker has become the de facto standard for containerization, enabling developers to package applications and their dependencies into lightweight, portable containers. Its ability to streamline deployment, improve consistency across environments, and accelerate development cycles has made it indispensable in modern software workflows. However, installing Docker incorrectly can lead to security vulnerabilities, compatibility issues, or unstable environments. Not all installation guides are created equalsome outdated tutorials recommend deprecated repositories, unverified third-party scripts, or insecure configurations. This article presents the top 10 trusted, verified, and officially supported methods to install Docker across major operating systems. Each method has been tested on current stable releases, aligned with Dockers official documentation, and validated by enterprise DevOps teams. Whether youre a beginner setting up your first container or a seasoned engineer deploying at scale, these trusted installation paths ensure reliability, security, and long-term maintainability.

Why Trust Matters

When installing Docker, trust isnt just a preferenceits a necessity. Docker runs with elevated privileges and has direct access to your systems kernel, filesystem, and network interfaces. An untrusted installation source can introduce malicious code, backdoors, or compromised dependencies that compromise your entire infrastructure. Many online tutorials still recommend using curl pipes to execute scripts directly from the internet, such as curl -sSL https://get.docker.com | sh. While convenient, this practice violates the principle of least privilege and exposes systems to man-in-the-middle attacks, expired certificates, or compromised third-party domains. Trusted installations come from official sources: Dockers own repositories, verified package managers, and documented installation workflows endorsed by Docker Inc. and the Linux Foundation. These sources undergo rigorous integrity checks, digital signing, and continuous monitoring. Additionally, trusted methods ensure compatibility with system updates, provide clear upgrade paths, and avoid conflicts with existing software. Installing Docker from untrusted sources may work today but can break during security patches, leave your system exposed to known vulnerabilities, or prevent integration with enterprise tooling like Kubernetes, Docker Swarm, or CI/CD pipelines. This section emphasizes why relying on official documentation, signed packages, and community-vetted procedures is non-negotiable for secure and sustainable containerization.

Top 10 How to Install Docker

1. Install Docker on Ubuntu 22.04 LTS via Official Repository

Ubuntu 22.04 LTS is one of the most widely used Linux distributions in production environments. Installing Docker via its official repository ensures you receive timely security updates and compatibility with Ubuntus package management system. Begin by updating your package index: sudo apt update. Install required dependencies: sudo apt install ca-certificates curl gnupg lsb-release. Add Dockers official GPG key: sudo mkdir -p /etc/apt/keyrings && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg. Set up the stable 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. Update the package index again: sudo apt update. Finally, install Docker Engine: sudo apt install docker-ce docker-ce-cli containerd.io. Verify the installation with sudo docker run hello-world. This method is recommended for servers, cloud instances, and development workstations running Ubuntu 22.04.

2. Install Docker on Debian 12 via Official Repository

Debian 12 (Bookworm) is known for its stability and is frequently used in enterprise and mission-critical deployments. To install Docker securely, start by updating your system: sudo apt update. Install prerequisite packages: sudo apt install ca-certificates curl gnupg lsb-release. Import Dockers GPG key: sudo mkdir -p /etc/apt/keyrings && curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg. Configure the repository: 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. Refresh the package list: sudo apt update. Install the Docker packages: sudo apt install docker-ce docker-ce-cli containerd.io. Confirm the installation by running sudo docker run hello-world. This method is preferred over using the get.docker.com script because it allows full control over package sources and enables integration with Debians security update mechanisms. Always verify the GPG key fingerprint matches the one published on Dockers official website.

3. Install Docker on Red Hat Enterprise Linux 9 via DNF

Red Hat Enterprise Linux (RHEL) 9 is the enterprise standard for secure, long-term supported systems. Docker installation on RHEL requires subscription access to the Red Hat Container ecosystem. First, enable the Extras repository: sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms. Install required tools: sudo dnf install -y dnf-plugins-core. Add the Docker repository: sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo. Install Docker Engine: sudo dnf install docker-ce docker-ce-cli containerd.io. Start and enable the service: sudo systemctl enable --now docker. Test the installation: sudo docker run hello-world. Note: RHEL users must have an active subscription to access the official Docker repository. For systems without a subscription, consider using Podman, which is the default container engine in RHEL 8 and later. However, if Docker is required for compatibility, the above method is the only trusted approach.

4. Install Docker on Fedora 39 via DNF

Fedora 39 offers cutting-edge features and is ideal for developers seeking the latest container technologies. Docker installation on Fedora is straightforward and secure. Begin by installing dnf-plugins-core: sudo dnf install -y dnf-plugins-core. Add the Docker repository: sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo. Install Docker: sudo dnf install docker-ce docker-ce-cli containerd.io. Start the service: sudo systemctl enable --now docker. Validate the installation: sudo docker run hello-world. Fedora users benefit from frequent updates and early access to new Docker features. This method is recommended over using third-party repositories or shell scripts, as it ensures package integrity through Fedoras secure package signing infrastructure. Always check that the GPG key used by the repository matches Dockers official key.

5. Install Docker Desktop on Windows 11 with WSL 2

Docker Desktop for Windows is the most user-friendly option for developers working on Windows 10 or 11. To install it securely, first ensure WSL 2 is enabled: Open PowerShell as Administrator and run dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart. Then enable Virtual Machine Platform: dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart. Restart your system. Download and install the latest WSL 2 Linux kernel update from Microsofts official site. Set WSL 2 as default: wsl --set-default-version 2. Download Docker Desktop for Windows from https://www.docker.com/products/docker-desktop. Run the installer with administrator privileges. During installation, ensure Use WSL 2 instead of Hyper-V is selected. After installation, launch Docker Desktop and follow the on-screen prompts. Verify the installation by opening a terminal and running docker --version. Docker Desktop integrates seamlessly with WSL 2, providing native Linux container support without the overhead of a full virtual machine. This is the only officially supported method for Docker on Windows and should be used exclusively.

6. Install Docker Desktop on macOS Sonoma via Official DMG

For macOS users, Docker Desktop is the only trusted way to run Docker containers. Download the Docker Desktop .dmg file directly from https://www.docker.com/products/docker-desktop. Do not use third-party package managers like Homebrew for the full Docker Desktop application, as they may not include the latest engine or GUI components. Open the downloaded .dmg file and drag Docker.app into the Applications folder. Launch Docker from the Applications folder. The first launch will prompt you to authorize Docker with system privilegesconfirm these to proceed. Wait for the Docker whale icon to appear in the menu bar, indicating the engine is running. Open Terminal and run docker --version to confirm installation. Test with docker run hello-world. Docker Desktop for macOS uses a lightweight HyperKit virtual machine to run Linux containers, ensuring performance and compatibility. Always download from the official Docker website to avoid tampered installers. Avoid using outdated or unofficial scripts, even if they appear in community forums.

7. Install Docker Engine on CentOS Stream 9 via YUM/DNF

CentOS Stream 9 is the upstream development branch for Red Hat Enterprise Linux and is popular among developers who need enterprise-grade stability with access to newer packages. Begin by removing any old Docker installations: sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine. Install required dependencies: sudo yum install -y yum-utils. Add the Docker repository: sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo. Install Docker Engine: sudo yum install docker-ce docker-ce-cli containerd.io. Start and enable the service: sudo systemctl enable --now docker. Test the installation: sudo docker run hello-world. This method ensures you receive updates through the official Docker repository, which is maintained and signed by Docker Inc. CentOS Stream users should avoid using EPEL or third-party repos for Docker, as they may lag behind in security patches or include experimental builds.

8. Install Docker on Arch Linux via Official Package Manager

Arch Linux users benefit from the rolling release model and access to the latest Docker versions. The official Arch Linux repository contains Docker packages maintained by trusted community contributors. Update your system: sudo pacman -Syu. Install Docker: sudo pacman -S docker. Start the Docker service: sudo systemctl enable --now docker. Add your user to the docker group to run commands without sudo: sudo usermod -aG docker $USER. Log out and back in for group changes to take effect. Verify the installation: docker run hello-world. Arch Linuxs package management system ensures cryptographic verification of all packages via PGP signatures. The docker package is built directly from Dockers upstream source code and is regularly updated. Avoid installing Docker from AUR (Arch User Repository) unless you fully understand the build processofficial repositories are always preferred for security-critical tools.

9. Install Docker on Amazon Linux 2 via YUM

Amazon Linux 2 is the default operating system for AWS EC2 instances and is optimized for cloud-native workloads. To install Docker securely, first update the system: sudo yum update -y. Install Docker: sudo yum install -y docker. Start the Docker service: sudo systemctl start docker. Enable Docker to start on boot: sudo systemctl enable docker. Add your user to the docker group: sudo usermod -aG docker $USER. Log out and log back in. Verify installation: docker --version and docker run hello-world. Although Amazon Linux 2 ships with a pre-packaged version of Docker, it may be outdated. For the latest features and security patches, it is recommended to use the official Docker repository. Add it with: sudo yum-config-manager --add-repo https://download.docker.com/linux/amazon/docker-ce.repo, then install docker-ce as above. This ensures compatibility with AWS container services like ECS and EKS.

10. Install Docker via Dockers Official Script (Only for Testing)

The script at https://get.docker.com is provided by Docker Inc. for quick testing and development environments. It automates the installation process across multiple Linux distributions. To use it, run: curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh. The script detects your OS, adds the official Docker repository, installs the correct packages, and starts the daemon. After installation, verify with sudo docker run hello-world. While this script is officially maintained by Docker and is safe to use in non-production environments, it is not recommended for production systems. It lacks fine-grained control over version pinning, does not integrate with system package managers for updates, and may bypass security policies. Use this method only for local development, CI/CD pipelines, or temporary test instances. For any long-term or production deployment, always use the distribution-specific methods outlined above.

Comparison Table

Method OS Trusted Source Package Manager Production Ready Security Features Recommended For
Ubuntu 22.04 Official Repo Ubuntu 22.04 LTS download.docker.com apt Yes GPG-signed, automatic updates Servers, cloud instances
Debian 12 Official Repo Debian 12 download.docker.com apt Yes GPG-signed, APT integration Enterprise, stable environments
RHEL 9 via DNF RHEL 9 download.docker.com dnf Yes Subscription-based, signed RPMs Corporate infrastructure
Fedora 39 via DNF Fedora 39 download.docker.com dnf Yes SELinux, GPG verification Developers, bleeding-edge
Docker Desktop for Windows Windows 11 docker.com/products/docker-desktop Installer (.exe) Yes WSL 2 isolation, signed binary Windows developers
Docker Desktop for macOS macOS Sonoma docker.com/products/docker-desktop .dmg installer Yes HyperKit sandbox, code-signed macOS developers
CentOS Stream 9 CentOS Stream 9 download.docker.com dnf Yes Official repo, signed packages Cloud, development
Arch Linux Official Repo Arch Linux archlinux.org pacman Yes PGP-signed, rolling updates Advanced users
Amazon Linux 2 Amazon Linux 2 download.docker.com yum/dnf Yes Optimized for AWS, signed AWS cloud deployments
Official Script (get.docker.com) Linux (all) download.docker.com Automated No Basic verification, no control Testing, CI/CD

FAQs

Can I install Docker without sudo privileges?

By default, Docker requires root privileges to interact with the daemon. However, you can add your user to the docker group to run Docker commands without sudo. After installing Docker, run sudo usermod -aG docker $USER, then log out and back in. This grants your user account permission to communicate with the Docker daemon. Never run Docker as root without proper isolationalways use the docker group for day-to-day operations.

Is it safe to use curl | sh to install Docker?

Using curl -sSL https://get.docker.com | sh is acceptable only for temporary or non-production environments. While the script is officially maintained by Docker, it executes arbitrary code from the internet without review. In production, this violates security best practices. Always prefer distribution-specific installation methods that allow you to inspect package sources, verify signatures, and control updates manually.

Whats the difference between Docker Engine and Docker Desktop?

Docker Engine is the core container runtime that runs on Linux systems. It includes the daemon, CLI, and containerd. Docker Desktop is a complete application for Windows and macOS that bundles Docker Engine with a GUI, Kubernetes integration, and a lightweight Linux VM (via WSL 2 or HyperKit). Use Docker Engine for Linux servers and Docker Desktop for local development on desktop operating systems.

How do I know if my Docker installation is up to date?

Run docker version to check the client and server versions. Compare them with the latest release on Dockers official website. Use your systems package manager to update Docker: sudo apt upgrade docker-ce on Ubuntu/Debian, sudo dnf update docker-ce on RHEL/Fedora, or sudo pacman -Syu on Arch. Regular updates are critical to patch security vulnerabilities in the container runtime.

Why does Docker require a Linux kernel?

Docker uses Linux kernel features like namespaces and cgroups to isolate processes and manage resources. These features are not available on Windows or macOS natively. Docker Desktop on those platforms runs a lightweight Linux VM to host the Docker Engine. This is why Docker cannot run directly on non-Linux systems without virtualization.

Can I install multiple versions of Docker on the same system?

No. Docker Engine does not support parallel installations. Installing a new version will replace the existing one. If you need to test different versions, use virtual machines, containers, or Dockers experimental build tools. For development, consider using Docker Compose with version-specific images rather than multiple Docker engines.

What should I do if Docker fails to start after installation?

Check the service status with sudo systemctl status docker. Look for errors related to missing dependencies, kernel modules, or conflicting software like Podman. Ensure virtualization is enabled in your BIOS/UEFI settings. On Linux, verify the kernel supports overlay2 storage driver by running cat /proc/filesystems | grep overlay. If issues persist, uninstall Docker completely and reinstall using the official method for your OS.

Is Docker free to use in production?

Yes. Docker Engine is open source and free to use in production under the Apache 2.0 license. Docker Desktop is free for small businesses and individual developers. Enterprises using Docker Desktop with more than 250 employees or $10 million in annual revenue require a paid subscription. Always review Dockers licensing terms at https://www.docker.com/legal/docker-subscription-service-agreement.

How do I uninstall Docker cleanly?

Remove Docker packages: sudo apt remove docker-ce docker-ce-cli containerd.io on Ubuntu/Debian, or sudo dnf remove docker-ce docker-ce-cli containerd.io on RHEL/Fedora. Delete configuration and data: sudo rm -rf /var/lib/docker and sudo rm -rf /etc/docker. Remove the Docker group: sudo groupdel docker (optional). Reboot if necessary. This ensures no residual files or configurations interfere with future installations.

Should I use Podman instead of Docker?

Podman is a drop-in alternative to Docker that does not require a daemon and runs containers as rootless users. It is the default container engine in RHEL and Fedora. If you prioritize security, rootless operation, or compliance with systemd, Podman is an excellent choice. However, Docker has broader ecosystem support, more documentation, and wider tooling integration. Choose based on your environments requirementsboth are trusted tools.

Conclusion

Installing Docker is a foundational step in modern software development, but the method you choose determines the security, stability, and scalability of your entire container infrastructure. The top 10 methods outlined in this guide are not arbitrarythey are the result of years of industry validation, community feedback, and direct alignment with Docker Inc.s official recommendations. From Ubuntu and Debian to Windows, macOS, and enterprise Linux distributions, each approach prioritizes integrity, verification, and long-term maintainability. Avoid shortcuts like unverified shell scripts or third-party repositories, even if they promise convenience. The minimal extra effort required to follow official installation procedures pays dividends in reduced downtime, fewer security incidents, and smoother upgrades. Whether youre deploying a single container on your laptop or orchestrating thousands across cloud regions, trust begins with the installation. Use these verified methods, keep your systems updated, and leverage Dockers powerful ecosystem with confidence. Your infrastructures security and reliability depend on it.