How to Install Docker on Ubuntu Server

Docker is one of the most popular ways to run applications in isolated containers on a Linux server. For Ubuntu servers, the recommended installation method is to install Docker Engine from Docker’s official APT repository, because it gives you a clean setup process and makes future updates easier to manage. This guide is written for Ubuntu servers, not Docker Desktop, and is suitable for VPS, cloud, and dedicated server deployments.

At the time of writing, Docker’s official Ubuntu installation guide lists support for the 64-bit versions of Ubuntu 26.04 LTS, 25.10, 24.04 LTS, and 22.04 LTS. Docker Engine for Ubuntu is also compatible with x86_64/amd64, armhf, arm64, s390x, and ppc64le architectures. Ubuntu derivative distributions such as Linux Mint are not officially supported, even though they may work in some cases.

Want the easier route?

👍
Installing Docker on your own server is not difficult when you follow the correct steps, but it still involves repository setup, package installation, service configuration, and verification.

If you would rather receive the server ready to use, Servers99 can provision your server with Ubuntu and Docker pre-installed before handover. You can simply open a support ticket or add the request in your order notes (conditions apply).

Prerequisitesn

Before you begin, make sure you have:

  • A 64-bit Ubuntu server
  • A user account with sudo privileges
  • Internet access
  • SSH access to the server

You can confirm your Ubuntu version and architecture with:

Bash cat /etc/os-release dpkg --print-architecture

Step 1: Remove old or conflicting Docker packages

Older packages provided by the Ubuntu repository can conflict with Docker’s official packages. Docker recommends removing packages such as docker.io, docker-compose, docker-compose-v2, docker-doc, podman-docker, containerd, and runc before installing the official version. Docker also notes that images, containers, volumes, and networks stored in /var/lib/docker/ are not automatically removed when you uninstall packages.

1
Run:
Bash sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)

♦️ If Ubuntu says some of those packages are not installed, that is normal.

Step 2: Update the package index

2
Run:
Bash sudo apt update

♦️ Start by refreshing your package list:

Step 3: Install the required dependencies

3
Run:
Bash sudo apt install ca-certificates curl

♦️ Docker’s official Ubuntu instructions use ca-certificates and curl before adding the Docker repository and keyring.

Step 4: Add Docker’s official GPG key

4
Add:
Bash sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc

♦️The current Docker installation method for Ubuntu uses a keyring file in /etc/apt/keyrings/ instead of the older apt-key method used in outdated tutorials.

Step 5: Add the Docker APT repository

5
Run:
Bash sudo tee /etc/apt/sources.list.d/docker.sources <<EOF Types: deb URIs: https://download.docker.com/linux/ubuntu Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") Components: stable Architectures: $(dpkg --print-architecture) Signed-By: /etc/apt/keyrings/docker.asc EOF

♦️Now add Docker’s official repository to your Ubuntu server. Docker’s current documentation uses a .sources file and automatically pulls the correct Ubuntu codename from /etc/os-release.

6
Run:
Bash sudo apt update

♦️ After adding the repository, refresh the package index again:

Step 6: Install Docker Engine

Docker’s recommended Ubuntu installation command installs Docker Engine, the Docker CLI, containerd, Buildx, and the Docker Compose plugin in one step.

7
Run:
Bash sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

♦️This gives you:

  • docker-ce — Docker Engine
  • docker-ce-cli — the Docker command-line tools
  • containerd.io — the container runtime
  • docker-buildx-plugin — extended image build support
  • docker-compose-plugin — docker compose support

Step 7: Check that Docker is running

♦️ Docker says the service usually starts automatically after installation, although some systems may require a manual start.

8
Run:
Bash sudo systemctl status docker

♦️ Check the service status:

9
Run :
Bash sudo systemctl start docker

♦️ If it is not running, start it manually:

Step 8: Verify the installation

Docker recommends testing the installation by running the hello-world container. This downloads a test image, runs it, prints a confirmation message, and then exits

10
Run:
Bash sudo docker run hello-world

If everything is working correctly, you should see a message beginning with:

👍
Hello from Docker!

Step 9: Check the installed Docker and Compose versions

Since the standard Ubuntu repository method also installs the Compose plugin, you can verify both Docker and Compose immediately after installation. Docker’s Compose documentation uses docker compose version as the verification command.

11
Run:
Bash docker --version docker compose version docker info

Step 10: Run Docker without sudo (optional)

By default, Docker uses a Unix socket owned by root, so regular users must run Docker commands with sudo. Docker’s post-installation guide explains that you can add your user to the docker group to run Docker commands without sudo, but it also warns that the docker group grants root-level privileges.

13
Run:
Bash sudo groupadd docker sudo usermod -aG docker $USER

♦️ Create the group and add your user

13
Run:
Bash newgrp docker

♦️ Then apply the change

14
Run:
Bash docker run hello-world

♦️ Now test it

15
Run:
Bash sudo chown "$USER":"$USER" /home/"$USER"/.docker -R sudo chmod g+rwx "$HOME/.docker" -R

♦️ If you previously used Docker with sudo and later see a permissions error involving ~/.docker/config.json, Docker’s post-install guide recommends fixing ownership and permissions like this

Step 11: Make sure Docker starts on boot

Docker’s post-installation guide says that on Debian and Ubuntu, Docker usually starts on boot by default. If you want to enable it explicitly, run:

16
Run:
Bash sudo systemctl enable docker.service sudo systemctl enable containerd.service
17
Run:
Bash sudo systemctl disable docker.service sudo systemctl disable containerd.service

♦️ If you ever want to disable that behavior

Step 12: Your first useful Docker commands

18
Run:
Bash docker ps docker ps -a docker images docker pull nginx docker run -d -p 80:80 --name mynginx nginx docker logs mynginx docker stop mynginx docker rm mynginx

♦️ Once Docker is installed, these are some of the first commands most users need

19
Run:
Bash mkdir docker-test cd docker-test nano compose.yaml

♦️ To test Docker Compose, create a small project directory

20
Run:
YAML services: web: image: nginx:latest ports: - "80:80"

♦️ Paste this into compose.yaml

21
Run:
YAML docker compose up -d docker compose ps docker compose down

♦️ Then run

Docker Compose is now distributed as the Compose plugin for Linux, and Docker’s documentation recommends the repository method for installing and updating it.

Important firewall note for Ubuntu servers

This part matters on public VPS and dedicated servers. Docker’s Ubuntu install guide warns that Docker is only compatible with iptables-nft and iptables-legacy, and that firewall rules created only with raw nft are not supported on a system with Docker installed. Docker also says firewall rules should be added to the DOCKER-USER chain when appropriate.

If you expose container ports with -p, make sure you understand how your firewall is configured before putting a service into production.

How to update Docker on Ubuntu

When Docker is installed from the official APT repository, updating it is straightforward. Docker’s Ubuntu guide says upgrades are handled by following the installation package step again and installing the newer version.

22
Run:
Bash sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
23
Run:
Bash apt list --all-versions docker-ce

♦️ If you want to see all available Docker Engine versions first

How to uninstall Docker

If you ever need to remove Docker completely, Docker’s Ubuntu documentation says you can purge the installed packages and then manually remove Docker data directories.

24
Run:
Bash sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras sudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd sudo rm /etc/apt/sources.list.d/docker.sources sudo rm /etc/apt/keyrings/docker.asc

Conclusion

Installing Docker on Ubuntu server is straightforward when you use Docker’s official APT repository. This method is the current recommended approach for Ubuntu, gives you Docker Engine plus the Compose plugin, and makes future updates much easier to manage. For most server deployments, this is the cleanest and most reliable way to get Docker running on Ubuntu today.

Prefer an automated setup?

If you want to speed up the process, you can also use our ready-to-run Docker install script for Ubuntu on GitHub. It follows the same official APT repository method covered in this tutorial.

Docker Install Script for Ubuntu

Recommended Choice

Need a Dedicated Server Ready for Docker?

Deploy containers faster with a high-performance Ubuntu dedicated server built for Docker workloads.

  • Ubuntu dedicated servers ready for Docker deployments
  • High-performance dedicated server hardware for production workloads
  • Fast and reliable bandwidth for stable container performance
  • Built-in DDoS protection for better uptime and security
  • Full root access so you can configure Docker exactly the way you want

If you would rather skip manual server preparation, choose a dedicated server optimized for Docker hosting. A properly configured Ubuntu dedicated server gives you the performance, bandwidth, security, and flexibility needed for containerized applications, staging environments, and production deployments.

Common mistakes to avoid

A common mistake is installing docker.io or leaving older Docker-related packages on the server before installing Docker Engine. Docker’s official Ubuntu guide says unofficial distro packages can conflict with Docker’s own packages, and it specifically tells users to remove packages such as docker.io, docker-compose, podman-docker, containerd, and runc first.
Many older guides still use the deprecated apt-key method or older repository instructions. Docker’s current Ubuntu installation guide uses a keyring file under /etc/apt/keyrings/ and a modern repository setup, so copying old commands from outdated blog posts can break the installation or leave users on the wrong setup path.
Another common mistake is trying to install the old standalone docker-compose binary, or assuming docker-compose is the preferred modern method. Docker’s own docs say the standalone Compose install is legacy, not recommended, and kept mainly for backward compatibility; the current recommended approach on Linux is the Docker Compose plugin used through docker compose.
This is a big one on public VPS and dedicated servers. Docker warns that when you publish ports, they can bypass ufw or firewalld rules, and Docker’s install guidance also says raw nft firewall rules are not supported in the normal iptables-based setup. Docker recommends handling custom filtering through the DOCKER-USER chain.