Linux

Installing Docker on Ubuntu: Step-by-Step Guide 2026

Detailed guide on installing Docker Engine on Ubuntu using the official repository. You'll get a working containerization environment with installation verification and basic configuration.

Updated at February 15, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04 LTSUbuntu 20.04 LTSUbuntu 18.04 LTS

Introduction / Why This Is Needed

Docker is an application containerization platform that allows you to package programs and their dependencies into portable containers. Installing Docker on Ubuntu will give you the ability to:

  • Deploy and run applications in isolated environments.
  • Simplify the development, testing, and deployment process.
  • Use ready-made images from Docker Hub (millions of containers).

After completing this guide, you will have a working Docker Engine environment, ready for development or production tasks.

Requirements / Preparation

Before you begin, ensure that:

  1. You have Ubuntu 18.04, 20.04, or 22.04 LTS installed.
  2. You have access to an account with sudo privileges.
  3. The system is updated (it is recommended to run sudo apt update && sudo apt upgrade).

⚠️ Important: Installing Docker on Ubuntu requires administrator privileges. All commands below assume the use of sudo.

Step-by-Step Instructions

Step 1: Update Package Cache

Update the local package cache to get information about the latest versions:

sudo apt update

Step 2: Install Dependencies

Install packages necessary for adding third-party repositories:

sudo apt install -y ca-certificates curl gnupg lsb-release

Step 3: Add the Official Docker GPG Key

Create a directory for keys and add Docker's 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

Step 4: Add the Docker Repository

Add the Docker repository to sources.list. Use the command corresponding to your Ubuntu version:

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

Step 5: Install Docker Engine

Update the cache again and install Docker:

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

Step 6: Start and Enable Autostart

Start the Docker service and configure it to start automatically on system boot:

sudo systemctl start docker
sudo systemctl enable docker

Step 7: Verify the Installation

Run the hello-world test container to verify the installation is correct:

sudo docker run hello-world

If you see a welcome message, Docker is installed correctly.

Step 8: Configure Permissions (Optional)

By default, Docker commands require sudo. To run Docker as a regular user, add them to the docker group:

sudo usermod -aG docker $USER

💡 Tip: After running this command, log out of your session and log back in (or reboot) for the changes to take effect.

Verification

  1. Check Docker version:
    docker --version
    

    The Docker Engine version should be displayed (e.g., Docker version 24.0.7, build afdd53b).
  2. Check service status:
    sudo systemctl status docker
    

    The status should be active (running).
  3. Run a container without sudo (if Step 8 was completed):
    docker run hello-world
    

    If the container runs without access errors, the permission configuration was successful.

Potential Issues

Error: docker: command not found

  • Cause: Docker is not installed or the executable path is not added to PATH.
  • Solution: Ensure the installation steps were performed correctly. Restart the terminal or run source ~/.bashrc.

Error: Got permission denied while trying to connect to the Docker daemon socket

  • Cause: The current user is not a member of the docker group.
  • Solution: Complete Step 8 (add to group) and log out and back into the system.

GPG Error When Adding Repository

  • Cause: The GPG key is missing or corrupted.
  • Solution: Repeat Step 3, ensuring the command completes without errors. Check for the existence of the file /etc/apt/keyrings/docker.gpg.

Ubuntu Version Conflict in Repository

  • Cause: The repository addition command uses $(lsb_release -cs), which may return a codename not supported by the Docker repository (e.g., for Ubuntu test builds).
  • Solution: Explicitly specify the LTS codename (e.g., jammy for Ubuntu 22.04) in the repository string instead of $(lsb_release -cs).

No Space Left on Device

  • Cause: Docker and its images require free disk space.
  • Solution: Clean up unused images: docker system prune -a. Ensure there is sufficient space in the /var/lib/docker partition.

F.A.Q.

Can Docker be installed on Ubuntu without sudo?
How to verify Docker is working correctly?
What to do if a GPG error occurs during installation?
How to update Docker to a new version?

Hints

Adding Docker's GPG key
Adding Docker repository
Installing Docker Engine
Starting Docker service
Verifying installation
Configuring access permissions
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