LinuxLow

Installing Docker CE on Linux: Detailed Guide for Ubuntu and CentOS

This guide covers installing Docker CE on Linux distributions. You'll learn to add repositories, install packages, and configure Docker for use.

Updated at February 17, 2026
10-15 minutes
Medium
FixPedia Team
Применимо к:Ubuntu 22.04 LTSDebian 11CentOS 8 StreamFedora 38

Introduction

Docker Community Edition (CE) is the free version of Docker, which allows you to package applications and their dependencies into portable containers. Installing Docker CE on Linux unlocks capabilities for rapid development, testing, and deployment of software in an isolated environment. This guide will help you set up Docker on popular Linux distributions such as Ubuntu, Debian, CentOS, and Fedora using the official Docker repository.

After following these instructions, you will be able to run Docker containers, manage images and networks, and use tools like Docker Compose. The process takes about 10–15 minutes and requires basic knowledge of working with the terminal.

Prerequisites

Before starting the installation, ensure your system meets the following requirements:

  • 64-bit Linux system: Docker CE supports x86_64, ARM, and other architectures, but this guide focuses on x86_64.
  • Terminal access with superuser (sudo) or root privileges.
  • Internet connection to download packages and the Docker repository.
  • Supported distribution: Ubuntu 20.04+, Debian 10+, CentOS 7+, Fedora 30+. For the latest list of supported versions, see the official Docker documentation.

💡 Tip: If you use a less common distribution, check if it has a Docker package in its official repositories, but for the latest versions, the official Docker repository is recommended.

Step 1: Update System and Install Dependencies

Before adding the Docker repository, update the package list and install necessary utilities. Commands differ for Debian/Ubuntu-based distributions (apt) and CentOS/Fedora (yum/dnf).

For Ubuntu and Debian

Run the following commands in the terminal:

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
  • apt update updates the package cache.
  • apt-transport-https allows using HTTPS repositories.
  • ca-certificates provides SSL certificate verification.
  • curl is used to download the GPG key.
  • software-properties-common adds the add-apt-repository command (optional but useful).

For CentOS and Fedora

For CentOS 7/8 and Fedora, use yum or dnf:

sudo yum update -y
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 curl
  • yum-utils provides the yum-config-manager utility.
  • device-mapper-persistent-data and lvm2 are required for Docker storage.
  • curl is for downloading the key.

⚠️ Important: On Fedora, you can use dnf instead of yum, but the commands are compatible. Ensure yum-utils is installed.

Step 2: Add the Official Docker Repository

Docker provides its own repository with up-to-date package versions. Add the Docker GPG key to verify package authenticity and configure the repository.

For Ubuntu and Debian

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
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
  • The first command downloads the Docker GPG key and saves it to /usr/share/keyrings/docker-archive-keyring.gpg.
  • The second command adds the repository to /etc/apt/sources.list.d/docker.list. Replace ubuntu with debian for Debian.
  • $(lsb_release -cs) automatically detects your distribution's codename (e.g., jammy for Ubuntu 22.04).

For CentOS and Fedora

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • This command adds the Docker repository for CentOS. For Fedora, the repository is similar, but sometimes https://download.docker.com/linux/fedora/docker-ce.repo is required. If errors occur, check the current URL in the Docker documentation.

💡 Tip: If the yum-config-manager command is unavailable, install yum-utils (see Step 1) or manually create a repository file at /etc/yum.repos.d/docker-ce.repo.

Step 3: Install Docker CE

After configuring the repository, install the Docker CE packages and additional components like Docker Compose (as a plugin) and BuildKit.

For Ubuntu and Debian

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  • docker-ce — the core Docker engine.
  • docker-ce-cli — the docker command-line client.
  • containerd.io — container management.
  • docker-buildx-plugin — build extension for creating images.
  • docker-compose-plugin — plugin for Docker Compose (instead of a separate binary).

For CentOS and Fedora

sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

The package names are the same. If you use dnf on Fedora, replace yum with dnf.

Step 4: Configure the Docker Service and User Permissions

By default, Docker requires superuser privileges. For convenience, configure the service to start automatically and add your user to the docker group.

# Start the Docker service
sudo systemctl start docker

# Enable autostart on system boot
sudo systemctl enable docker

# Add the current user to the docker group
sudo usermod -aG docker $USER

⚠️ Important: After adding a user to the docker group, you must log out and log back in for the changes to take effect. Alternatively, run newgrp docker in the current terminal, but this will only work for that session.

Step 5: Verify the Installation

To confirm Docker is working correctly, run the hello-world test container:

docker run hello-world

If the installation was successful, you will see a welcome message confirming that Docker can pull images and run containers. Example output:

Hello from Docker!
This message shows that your installation appears to be working correctly.
...

Potential Issues

Common errors that may occur when installing Docker CE on Linux include:

  • Permission denied error: Ensure the user is added to the docker group (see Step 4) and has re-logged in. Check group membership: groups $USER.
  • Docker service not running: Check service status: sudo systemctl status docker. If inactive, start it: sudo systemctl start docker.
  • Repository addition error: Verify the GPG key was added correctly (ls /usr/share/keyrings/docker-archive-keyring.gpg) and the repository URL matches your distribution. For Debian, replace ubuntu with debian in the repository addition command.
  • Package conflicts on Fedora: Fedora may have its own Docker package versions in repositories. If conflicts arise, disable the Fedora repository for Docker or use the official Docker repository with a specified version.
  • Outdated dependencies: Older distributions may lack required packages. Update your system or consider using a newer distribution version.

If the issue persists, check Docker logs: sudo journalctl -u docker.service and search for solutions in the Docker community or official documentation.

F.A.Q.

Is a reboot required after installing Docker?
Can Docker be installed on Raspberry Pi?
What to do if the docker command returns 'permission denied'?
How to update Docker to a new version?

Hints

Update the system and install dependencies
Add the official Docker repository
Install Docker CE and related packages
Start the Docker service and configure autostart
Add the user to the docker group
Verify the installation with hello-world
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community