Customer Support

  1. Support
  2. How to install Docker Engine on Ubuntu
  1. Home
  2. Dedicated / VPS
  3. How to install Docker Engine on Ubuntu
  1. Home
  2. Dedicated / VPS Management
  3. How to install Docker Engine on Ubuntu
  1. Home
  2. Dedicated / VPS Management
  3. How to install Docker Engine on Ubuntu

How to install Docker Engine on Ubuntu

The Docker Engine allows you to build, run, and manage containers on Ubuntu. Below is a detailed, knowledge base–ready guide that walks you through installation, configuration, and verification of Docker’s functionality.


Prerequisites

  • Ubuntu 22.04 LTS or newer.
  • A user account with sudo privileges.
  • Internet access.

If you have older Docker packages installed (dockerdocker.iocontainerd, or runc), remove them first:

sudo apt remove docker docker-engine docker.io containerd runc

This will not remove existing images, containers, volumes, or configuration files.


Step 1: Set up the Docker repository

Add Docker’s official repository to your system to ensure you install the latest version of Docker Engine.

1. Update packages and install dependencies

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

2. Add Docker’s official GPG key

sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg

3. Add the stable Docker 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

4. Update your package index

sudo apt update

You can verify that the Docker packages come from the official repository:

apt-cache policy docker-ce | sed -n '1,6p'

Step 2: Install Docker Engine, CLI, and plugins

Install Docker Engine along with the CLI, containerd, Buildx, and Compose plugin:

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

To see which versions are available before installing:

apt-cache madison docker-ce

To install a specific version, use the <VERSION_STRING> from the previous command:

sudo apt install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> \ containerd.io docker-buildx-plugin docker-compose-plugin

Step 3: Verify the installation

Check that the Docker service is active and running:

sudo systemctl status docker

Then run a test container to confirm everything works:

sudo docker run --rm hello-world

If you see the message “Hello from Docker!”, your installation was successful.


Step 4: Run Docker without sudo (optional)

By default, Docker commands require sudo. To run them as your regular user, add yourself to the docker group and log out/in again:

sudo usermod -aG docker $USER # Log out and back in, then run: docker ps

If the command runs successfully without sudo, the change has been applied correctly.


Step 5: Enable automatic startup and manage Docker

Ensure Docker starts automatically at system boot:

sudo systemctl enable docker

Basic service management commands:

sudo systemctl start docker sudo systemctl stop docker sudo systemctl restart docker sudo systemctl status docker

Quick checks for version and system info:

docker --version docker info

Step 6: Upgrade or uninstall Docker

Upgrade Docker

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

Uninstall Docker completely

sudo apt -y purge docker-ce docker-ce-cli containerd.io \ docker-buildx-plugin docker-compose-plugin sudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd

Deleting /var/lib/docker and /var/lib/containerd removes all containers, images, and volumes.


Troubleshooting (Quick Reference)

  • Permission denied on socket: Run usermod -aG docker $USER and log out/in.
  • Hello-world fails: Check your internet connection and verify Docker is running (systemctl status docker).
  • Conflict with old docker.io: Remove it (sudo apt remove docker.io) and confirm you’re using the official Docker repository.

Completion

You have successfully installed Docker Engine on Ubuntu. You can now create and manage containers, use the Docker Compose plugin, and automate your development and deployment workflows with confidence.


You haven't found what you are looking for?

Contact our experts, they will be happy to help!

Contact us