Containers and Kubernetes · Beginner · 11 min
How to Install Docker Engine on Ubuntu 26.04
By Padding · Updated 15 Nov 2026
Ubuntu 26.04.1 LTS · Docker Engine 29
You will install Docker Engine 29 from Docker's official apt repository on Ubuntu 26.04, run the hello-world image to prove it works, and set it up to start at boot, run without sudo and keep its logs from filling the disk.
On this page
Docker Engine is the program that builds container images and runs containers on a Linux server. A container packs an app with everything it needs, so the same image runs the same way on your laptop and on the server.
Ubuntu has its own docker.io package, but it lags behind the releases from Docker. This tutorial uses Docker's own apt repository, which carries Docker Engine 29 for Ubuntu 26.04 and gets updates through the normal apt upgrade. You will add the repository, install Engine, run a test container, and make three adjustments that most servers need. It is the first tutorial in the series From Docker to Kubernetes.
Step 1 · Remove conflicting packages
If this is a fresh server, skip to the next step: there is nothing to remove. If you have ever installed Docker, Podman's Docker shim, or Ubuntu's own packages, they conflict with Docker's packages.
The command below removes the packages it lists. It does not delete images, containers or volumes, which live in /var/lib/docker, but it does remove a running Docker. Check that no important container depends on the old install first.sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc podman-docker containerd runc | cut -f1)Run dpkg -l | grep -E 'docker|containerd|runc' first. If it lists nothing, skip the command above.
Step 2 · Add Docker's apt repository
Install the tools that fetch the signing key, then store the key where apt can read it:
sudo apt update
sudo apt install ca-certificates curl
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.ascAdd the repository. The file names your Ubuntu release code name, which is resolute on 26.04, and your CPU architecture, so one command works on x86-64 and ARM64 servers:
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
sudo apt updateCheck it worked
cat /etc/apt/sources.list.d/docker.sources
apt-cache policy docker-ceThe file shows Suites: resolute. The Candidate line of apt-cache policy shows a version that starts with 5:29., with download.docker.com as the source. The 5: is an apt epoch number, and the Docker Engine version is 29.
Step 3 · Install Docker Engine
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginThe packages are:
docker-ceis the Engine, the daemon that runs containers, anddocker-ce-cliis thedockercommand.containerd.iois the lower-level runtime that the Engine uses.docker-buildx-pluginaddsdocker buildx, the modern image builder, anddocker-compose-pluginaddsdocker compose.
The package installs and starts the service, and turns it on for every boot. Check its state:
sudo systemctl status dockerYou want Active: active (running). Press q to leave the status view. If it is not running, start it with sudo systemctl enable --now docker.
Check it worked
docker --version
docker compose versionThe first prints Docker version 29. and a build number. The second prints Docker Compose version v5. and a number.
Step 4 · Run a test container
Run Docker's small test image. Docker downloads it on first use, creates a container, runs it and removes it (--rm):
sudo docker run --rm hello-worldThe output includes Hello from Docker! and a numbered list that explains what just happened: the client contacted the daemon, the daemon pulled the image, ran it, and streamed its output back to you. If you see that message, Docker works.
Troubleshooting
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?: the service is stopped. Runsudo systemctl start docker, and read the reason withsudo journalctl -u docker -n 50.permission denied while trying to connect to the Docker daemon socket: you randockerwithoutsudoand your user is not in thedockergroup. The next step handles it.Unable to find image 'hello-world:latest' locallyfollowed by a timeout or a TLS error: the server cannot reach Docker Hub. Check DNS and outbound access withcurl -I https://registry-1.docker.io/v2/, which should answer with a401status. That is correct: the registry wants a login for that path, and the answer proves you reached it.E: Unable to locate package docker-ce: the repository file has a typo, orapt updateprinted an error. Runsudo apt updateagain and read the lines aboutdownload.docker.com.
Step 5 · Run docker without sudo
By default only root and members of the docker group can talk to the daemon. The package creates the group. Add your user to it:
Membership in thedockergroup is the same as having root on the machine. Anyone in the group can start a container that mounts the host's whole filesystem and edit any file on it. Add only people you would givesudoto.
sudo usermod -aG docker $USERThe -a appends to your groups and -G names the group. Without the -a, usermod replaces all your other groups and can remove your own sudo rights. Group changes apply to new login sessions only. Log out and back in, or start a shell with the new group:
newgrp dockerCheck it worked
id
docker run --rm hello-worldThe id output lists docker among your groups, and the second command works without sudo.
Step 6 · Keep container logs from filling the disk
By default Docker stores each container's output in a file that grows without limit. A chatty container can fill the server's disk over a few weeks. Set a size limit for every new container in the daemon's configuration file.
Read both warnings before you run the command. First, the command replaces/etc/docker/daemon.json. If that file already exists, check it withcat /etc/docker/daemon.jsonand merge these keys into it by hand instead. Second, restarting Docker afterwards stops every running container unless the same file sets"live-restore": true, so do this on a server where a short interruption is acceptable.
sudo tee /etc/docker/daemon.json <<'EOF'
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}
EOFEach container then keeps at most three log files of 10 MB. Restart Docker so it reads the file:
sudo systemctl restart dockerThe change applies to containers you create after the restart. Containers that already exist keep their old settings until you recreate them.
Check it worked
docker info --format '{{.LoggingDriver}}'The output is json-file. To confirm the limits on a new container, run docker run -d --name logtest alpine sleep 60 and then docker inspect --format '{{.HostConfig.LogConfig}}' logtest, which shows the max-size and max-file options. Remove it with docker rm -f logtest.
Step 7 · Know what Docker does to your firewall
Docker adds its own firewall rules, and they come before the ones UFW manages. A port you publish with -p, as in docker run -p 8080:80 nginx, is open to the internet even if UFW denies it. To publish a port to the server itself only, bind it to the loopback address:
docker run -d -p 127.0.0.1:8080:80 nginxPut a reverse proxy such as Nginx on the host in front of it, and publish only the proxy's ports. The UFW tutorial, /tutorials/set-up-ufw-firewall-ubuntu-26-04, has a short note on this at the end.
Next steps
- Build an image for your own app:
/tutorials/write-a-dockerfile-for-a-node-app. - Run an app and a database together:
/tutorials/docker-compose-app-with-postgres. - Harden how you log in to the server:
/tutorials/harden-ssh-on-ubuntu-26-04. - The reference for these steps is Docker's installation guide for Ubuntu at docs.docker.com/engine/install/ubuntu/.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials