To install Docker on Ubuntu, add Docker’s official Advanced Package Tool (APT) repository to your system, and install the Docker Engine (docker-ce) package together with its plugins. This is the recommended method for manual installations. Using Docker’s repository gives you upstream releases and lets you update Docker with the same apt commands you use for everything else on your Ubuntu system.
The manual installation takes four stages:
- Remove packages that conflict with Docker Engine.
- Add Docker’s official APT repository.
- Install Docker Engine and its plugins.
- Verify that Docker is installed and running.
Hostinger customers can also forgo the manual work altogether and deploy a virtual private server (VPS) with Docker already bundled in. This guide covers both installation methods, explains how to configure Docker permissions, and shows you how to troubleshoot common installation errors and run your first container.
What do you need before installing Docker on Ubuntu?
To install Docker on Ubuntu, make sure you have:
- A 64-bit Ubuntu version that Docker supports. Docker Engine currently supports four Ubuntu releases, from 22.04 LTS to 26.10.
- Terminal access. On a desktop, any terminal app works. On a server or VPS, connect over Secure Shell (SSH).
- A user with
sudoprivileges. Every installation command needs root access. - An internet connection. Your system downloads Docker’s signing key and packages during setup.
It’s worth understanding Docker and containerization before you set anything up if you’re new to containers.
Which Ubuntu versions does Docker support?
As of November 2026, Docker Engine supports these Ubuntu releases:
- Ubuntu 26.10 (Stonking)
- Ubuntu 26.04 LTS (Resolute)
- Ubuntu 24.04 LTS (Noble)
- Ubuntu 22.04 LTS (Jammy)
Docker adds support for new Ubuntu releases and drops end-of-life ones, so check the Docker version requirements in their documentation for the current list.
This tutorial uses a VPS running on Ubuntu 26.10, but the process is the same on any supported release.
To confirm your Ubuntu version and codename, run:
cat /etc/os-release
Look at the VERSION_ID and VERSION_CODENAME lines in the output. Then check your architecture:
dpkg --print-architecture
Most desktop PCs and x86-based servers return amd64, but you may also encounter arm64 on specific servers. Knowing your CPU architecture is important to make sure you download the right package.

Existing packages can conflict with Docker Engine if you’ve installed Docker or another container runtime before.
How to install Docker on Ubuntu using the official APT repository
To install Docker on Ubuntu from the official APT repository, remove conflicting packages, add Docker’s repository, install Docker Engine with its plugins, and verify the installation. This method works the same way on an Ubuntu desktop, a home server, or a VPS. The commands detect your Ubuntu version and CPU architecture automatically, so they run unchanged on any supported release.
1. Remove conflicting Docker packages
Before installing Docker Engine, remove the unofficial Docker-related packages that Ubuntu’s own repositories ship, such as docker.io, plus older Docker Compose packages and their own builds of containerd and runc. Docker’s repository provides its own versions of these components, so leaving the distribution packages in place can cause package conflicts and leave incompatible Docker components installed.
Docker currently lists these packages as conflicting: docker.io, docker-compose, docker-compose-v2, docker-doc, docker-buildx, podman-docker, containerd, and runc. To remove any installed package from your system, run:
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)
The command checks which of these packages are installed and passes the matching package names to apt remove. APT removes nothing and reports 0 packages to remove if none are installed.
Removing these packages doesn’t automatically delete existing images, containers, volumes, or networks stored in /var/lib/docker/; they stay on disk. Back up your volumes and configuration files before you continue if you’re replacing a Docker installation that runs production workloads.
Docker may also have been installed through Snap. To check whether a Docker Snap package is present, run:
snap list docker
Remove the Docker snap before you continue if the command lists one:
sudo snap remove docker
Like the APT packages, a snap installation keeps its own data, so back up anything you still need from it first.
2. Add Docker’s official APT repository
First, refresh your package index and install the two tools the repository setup needs, ca-certificates and curl:
sudo apt update sudo apt install ca-certificates curl
ca-certificates lets your system verify HTTPS connections, while curl sends the HTTPS requests; together, they download Docker’s signing key securely. Enter Y and press Enter if APT prompts you to confirm the installation.

Then, create a directory for APT keyrings, download Docker’s GNU Privacy Guard (GPG) key into it, and make the key readable:
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
APT uses this key to verify the authenticity of Docker’s repository metadata. It then checks downloaded packages against the checksums in that metadata to ensure they haven’t been modified.
Now add the repository itself. This command writes a repository definition to /etc/apt/sources.list.d/docker.sources:
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
EOFThe Types: deb and URIs lines tell APT that the repository contains binary packages hosted on Docker’s download server. Here’s what the remaining lines do:
- Suites sets the repository’s distribution name, taking it from your system’s information, such as
noblefor Ubuntu 24.04. This tells APT which exact packages to retrieve. - Components: stable limits APT to Docker’s stable release channel.
- Architectures, as with suites, fetches the CPU architecture of your machine from the system.
- Signed-By tells APT to trust this repository only when its metadata is signed with the key you just downloaded.
Finally, refresh the package index so APT can see the new repository:
sudo apt update
You should see download.docker.com among the sources in the output.

A previous Docker installation might have left a repository definition in /etc/apt/sources.list.d/docker.list. An outdated or duplicate entry can cause APT errors when you add the new repository configuration. See the troubleshooting table below if apt update reports repository conflicts.
3. Install Docker Engine and the required plugins
With the repository in place, install Docker Engine and its plugins:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Press Y and Enter when APT asks you to confirm. This command installs five packages:
- docker-ce is Docker Engine, the background service (daemon) that builds and runs containers.
- docker-ce-cli is the Docker command-line tool you use to talk to the daemon.
- containerd.io provides the container runtime that Docker Engine uses to manage container lifecycles.
- docker-buildx-plugin adds Docker Buildx, an extended build tool that provides advanced BuildKit features, including multi-platform image builds.
- docker-compose-plugin adds Docker Compose, which defines and runs multi-container applications from a YAML configuration file.
Compose is installed as a command-line interface (CLI) plugin, so it’s run as docker compose, with a space, instead of the legacy Compose packages’ docker-compose command. To run more than one container at a time, read our guide to Docker Compose for multi-container applications.
Why use Docker’s repository instead of running sudo apt install docker.io? Ubuntu, not Docker, maintains docker.io, so it can lag behind upstream releases. Installing from Docker’s repository gives you the latest upstream releases, including Buildx and Compose plugins, and makes future updates available through APT. The repository setup is a one-time step.
4. Verify Docker is installed and running
Start by checking the installed version:
docker --version
The output shows the installed Docker version and its build identifier, which confirms the Docker CLI is installed.
Next, check if the Docker service is running:
sudo systemctl status docker
Look for active (running) in the output. Press Q to return to the prompt.

Start the service manually if the status is inactive or failed:
sudo systemctl start docker
Usually, the Docker service starts on boot. Enable it with the following command if it doesn’t start automatically on your system:
sudo systemctl enable docker
Next, run a test container:
sudo docker run hello-world
The hello-world image is a minimal test image used for verifying your installation. When everything works, the container prints a message that begins with Hello from Docker! and explains the steps Docker just took.
That message confirms the whole chain works: the CLI reached the daemon, the daemon pulled an image over the internet, and Docker successfully created and ran a container.

Finally, confirm that the Compose plugin is available:
docker compose version
Docker is now installed and working. For the commands you’ll use daily to manage images, containers, and volumes, see our list of essential Docker commands.
How to install Docker on Ubuntu using Hostinger’s VPS template
To skip the manual steps on a Hostinger VPS, install the Ubuntu with Docker operating system (OS) template, which comes with Docker pre-configured.
To install the Docker template on an existing VPS:
- Log in to the Hostinger dashboard, go to the VPS section, and click Manage next to your server.
- On the sidebar, expand OS & Panel and select Operating System.
- Find Docker among the application templates and select one. The two matching installations have differing Ubuntu releases – we recommend picking the latest version available unless you have a specific reason to run an older Ubuntu release.
- Confirm the OS change, acknowledge the data loss warning, and set a root password when prompted.
- Wait for the installation to finish.
Warning! Changing the operating system on an existing VPS permanently deletes all existing data on the VPS, including any stored snapshots. Back up any files, databases, and configuration you want to keep before you start.
When you create a new VPS, you can pick the Docker template during the initial server setup instead, so there’s no existing data to lose.
After the installation finishes, connect to your VPS using your preferred method, then verify Docker exactly as in step 4 of the manual method:
- Run
docker --version. - Check
sudo systemctl status docker. - Run
sudo docker run hello-world.
How do you run Docker without sudo on Ubuntu?
To run Docker without sudo on Ubuntu, add your user to the docker group. By default, the Docker daemon runs with root privileges, and only root and members of the docker group can access it. That’s why commands that talk to the daemon, such as docker run, needed sudo so far. This step is optional – before you change it, understand what group membership grants.
The docker group grants root-level privileges to its members. Any user in the group can start a container that mounts the host’s filesystem, then modify system files and take full control of the host.
Running Docker without sudo is a convenience, not a security improvement, so only add users you’d trust with sudo privileges anyway.
To add your current user to the group, run:
sudo usermod -aG docker $USER
The Docker packages normally create the docker group during installation, but if the group doesn’t exist, create it with:
sudo groupadd docker
Then, run the command again.
Group changes apply only to new login sessions. To apply the change, log out and back in or activate the new group in your current shell:
newgrp docker
On a VPS, closing the current session and reconnecting has the same effect. Now verify that it works without sudo:
docker run hello-world
The Hello from Docker! message confirms that Docker now works without sudo.
The most common causes of a “permission denied” error mentioning /var/run/docker.sock are:
- Your current session predates the group change. Log out fully and log back in.
- You added a different user than the one you’re logged in as. Run
groupsto see your current groups. - You ran Docker with
sudobefore the change, and your~/.dockerfolder is now owned by root.
Our guide to fixing Docker permission errors walks through these and other cases in detail.
To run Docker without root-level access at all, look into Docker’s rootless mode, which runs the Docker daemon and containers under a non-root user, reducing the impact of a compromised daemon or container. However, it takes extra effort to set up and has some trade-offs:
- Containers cannot publish ports below 1024 by default, including 80 (HTTP) and 443 (HTTPS).
- User-mode networking is slower.
- Containers aren’t able to see client IP addresses by default.
- Overlay networking and Stream Control Transmission Protocol (SCTP) ports are not supported.
How do you troubleshoot Docker installation errors on Ubuntu?
To troubleshoot Docker installation errors on Ubuntu, match the error message to its cause, then fix one of four things: the APT repository setup, the Docker service, your docker group membership, or network access to Docker Hub.
The table below lists the most common errors, their likely causes, and the commands that fix them.
| Error | Likely cause | Solution |
|---|---|---|
E: Unable to locate package docker-ce | The Docker repository wasn’t added, sudo apt update wasn’t run afterward, or your Ubuntu release isn’t supported | Check that /etc/apt/sources.list.d/docker.sources exists, run sudo apt update, and confirm your release with cat /etc/os-release |
NO_PUBKEY or The following signatures couldn't be verified | Docker’s GPG key is missing, incomplete, or unreadable | Re-run the GPG-key download and permission commands from step 2, confirm that Signed-By points to /etc/apt/keyrings/docker.asc, then run sudo apt update again |
Conflicting values set for option Signed-By | An old docker.list file from a previous installation points to a different key | Remove the obsolete repository file with sudo rm /etc/apt/sources.list.d/docker.list, then run sudo apt update |
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? | The Docker service is stopped or failed to start | Run sudo systemctl start docker, then check the logs with sudo journalctl -u docker |
permission denied while trying to connect to the Docker daemon socket | Your user isn’t in the docker group, or your session hasn’t picked up the change | Use sudo, or follow the section on running Docker without sudo |
hello-world fails with a timeout or Domain Name System (DNS) error | The server can’t reach Docker Hub because of a network, DNS, or proxy problem | Test name resolution with getent hosts registry-1.docker.io and check your network settings |
toomanyrequests when pulling images | Docker Hub applies pull rate limits, which are lower for unauthenticated users | Check your current pull limits, wait for the limit to reset, or authenticate with docker login to access the higher limits available to signed-in users |
docker: 'compose' is not a docker command | The Docker Compose plugin installation has failed | Run sudo apt install docker-compose-plugin |
Run these two commands to diagnose errors that aren’t in the table:
apt-cache policy docker-ce
This shows which repository APT would install docker-ce from. A healthy setup lists https://download.docker.com/linux/ubuntu with a candidate version. APT can’t see the Docker repository if the candidate is (none).
sudo journalctl -u docker --no-pager -n 50
This prints the last 50 log lines from the Docker service. When the daemon refuses to start, the reason, such as an invalid /etc/docker/daemon.json file, usually appears near the end.
Avoid these common fixes, which trade a quick workaround for a security gap or a broken setup:
- Don’t open Docker’s application programming interface (API) ports, like 2375 or 2376, to fix an installation error. A standard installation doesn’t need them; the CLI talks to the daemon through a local socket. According to Docker’s guide to protecting the Docker daemon socket, anyone with access to the daemon has root access to the host, so exposing the API to the network hands your server to anyone who finds the port.
- Don’t disable AppArmor to get a container running. It’s one of the security layers that isolates containers from the host. Find the specific denial in the logs and adjust that rule instead, following the principle of least privilege.
- Don’t delete Docker’s default bridge network. Docker manages it, and removing it rarely fixes an installation problem and can do more harm than good.
How to run your first Docker container
To run your first Docker container, choose a pre-built image from Docker Hub, such as a web server or a database, and start it with the docker run command. The hello-world container proves your installation works, but it exits right after printing its message.
Pulling a ready-made image is a quick way to learn how Docker handles ports, volumes, and container lifecycles before you start writing your own Dockerfiles. Follow our tutorial to create your first Docker container and put your new installation to work.
This article is a localized version of How to install Docker on Ubuntu, originally published in English.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.