-
Get in touch
- Servers99
611 Gateway Blvd ,
South San Francisco ,
CA 94080 United States - [email protected]
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?
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
sudoprivileges - Internet access
- SSH access to the server
You can confirm your Ubuntu version and architecture with:
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.
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
sudo apt update
♦️ Start by refreshing your package list:
Step 3: Install the required dependencies
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
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
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.
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.
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
♦️This gives you:
docker-ce— Docker Enginedocker-ce-cli— the Docker command-line toolscontainerd.io— the container runtimedocker-buildx-plugin— extended image build supportdocker-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.
sudo systemctl status docker
♦️ Check the service status:
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
sudo docker run hello-world
If everything is working correctly, you should see a message beginning with:
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.
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.
sudo groupadd docker
sudo usermod -aG docker $USER
♦️ Create the group and add your user
newgrp docker
♦️ Then apply the change
docker run hello-world
♦️ Now test it
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:
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
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
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
mkdir docker-test
cd docker-test
nano compose.yaml
♦️ To test Docker Compose, create a small project directory
services:
web:
image: nginx:latest
ports:
- "80:80"
♦️ Paste this into compose.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.
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
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.
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.
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
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.
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.
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.
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.