How to Install Docker on Ubuntu (Engine + Desktop, the Right Way)
If you want to install Docker on Ubuntu correctly the first time, the short answer is: add Docker’s official `apt` repository, then install `docker-ce`. That single decision—using Docker’s own repository instead of the package Ubuntu ships—separates a clean, up-to-date container host from the version headaches that send people back to search results a week later.
This guide walks through a production-grade Docker setup on Ubuntu: prerequisites, the difference between Docker Engine and Docker Desktop, the recommended repository install (with full commands), verification, and the post-install steps that actually matter—running Docker without `sudo` and enabling it on boot.
Key Takeaways
• The recommended way to install Docker Engine on Ubuntu is via Docker’s official `apt` repository, which gives you the current version and a clean update path.
• Docker Engine is for servers and CLI workflows; Docker Desktop is a GUI app for developer laptops—do not install Desktop on a headless server.
• Avoid `apt install docker.io`—it pulls Ubuntu’s bundled, often older build, which is the single most common Docker-on-Ubuntu mistake.
• After install, add your user to the `docker` group to run Docker without `sudo`, and `systemctl enable docker` so it starts on boot.
• Verify with `docker –version` and `sudo docker run hello-world` before doing anything else.
What do you need before installing Docker on Ubuntu?
Before you run a single command, confirm the basics. Docker is forgiving about Ubuntu releases but unforgiving about architecture and permissions.
Prerequisites for a Docker setup on Ubuntu:
- A supported Ubuntu version. Docker Engine supports current LTS releases (24.04, 22.04, 20.04) and recent non-LTS releases. If you are on an end-of-life Ubuntu, upgrade first.
- A 64-bit (x86_64/amd64 or arm64) system. Docker Engine does not run on 32-bit Ubuntu. Check with `uname -m`—you want `x86_64` or `aarch64`.
- `sudo` (root) access. Installing packages, managing the Docker service, and adding apt repositories all require root.
- A working internet connection to reach `download.docker.com`.
“`bash
uname -m lsb_release -a “`
If `uname -m` returns `x86_64` or `aarch64` and `lsb_release` shows a supported release, you are clear to proceed.
Docker Engine vs Docker Desktop on Ubuntu — which one do you need?
This is the question that trips up the most people, so let’s settle it before installing anything. Both are “Docker,” but they target very different machines.
Docker Engine is the core container runtime: the `dockerd` daemon, the `docker` CLI, `containerd`, and the build/compose plugins. It runs natively on Ubuntu with no virtualization layer. This is what you want on servers, VPS instances, CI runners, and any headless box.
Docker Desktop is a GUI application that bundles the engine inside a managed Linux VM, plus a dashboard, Kubernetes, and developer tooling. On Ubuntu it is meant for developer laptops/workstations where you want a graphical interface. The “docker desktop ubuntu” search usually comes from devs on a desktop machine—but if you are on a server, you almost never want it.
| Factor | Docker Engine | Docker Desktop |
|---|---|---|
| Best for | Servers, VPS, CI, headless hosts | Developer laptops/workstations |
| Interface | CLI only | GUI dashboard + CLI |
| Runs natively on Ubuntu | Yes (no VM) | No (runs inside a managed VM) |
| Resource overhead | Minimal | Higher (VM-based) |
| Includes Kubernetes UI | No | Yes |
| Install source | Docker `apt` repo (`docker-ce`) | `.deb` package from Docker |
| Typical use case | Production container hosting | Local development with a GUI |
The single most common Docker-on-Ubuntu mistake is installing the wrong package. People run `apt install docker.io`—Ubuntu’s bundled package, which is often several versions behind—or they grab Docker Desktop on a headless server, where a GUI VM-based app has no business running. For a server you want Docker Engine from Docker’s own apt repo, which gives you the current release and the official update path. Get this one choice right at install time and you sidestep the entire “why is my Docker old or behaving weirdly?” class of problems before it ever starts.
How do you install Docker Engine from the official apt repository?
This is the recommended method. It configures Docker’s repository so future `apt upgrade` runs keep Docker current, and it installs the engine plus the modern Compose and Buildx plugins.
Step 1: Remove any old or conflicting packages
Old, unofficial, or distro-bundled Docker packages will conflict with the official ones. Remove them first.
“`bash for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove -y $pkg done “`
It is fine if `apt` reports that some of these packages are not installed.
Step 2: Set up Docker’s apt repository and GPG key
Install the prerequisites, add Docker’s official GPG key, then add the repository to your apt sources.
“`bash
sudo apt-get update sudo apt-get install -y 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.asc
echo \ “deb [arch=$(dpkg –print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo “$VERSION_CODENAME”) stable” | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null “`
The `$(. /etc/os-release && echo “$VERSION_CODENAME”)` snippet auto-detects your Ubuntu release (e.g., `noble`, `jammy`) so you do not hardcode it.
Step 3: Install Docker Engine and the plugins
Refresh apt so it sees the new repository, then install the engine, CLI, containerd, and the official plugins.
“`bash sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin “`
That installs everything you need: `docker-ce` (the engine), `docker-ce-cli` (the command-line client), `containerd.io` (the container runtime), plus the Buildx and Compose plugins for `docker buildx` and `docker compose`.
Is there a faster way to install Docker on Ubuntu?
Yes—Docker provides a convenience script that automates the repository setup for you. It is handy for throwaway VMs and quick tests:
“`bash curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh “`
A word of caution: the convenience script runs with root privileges and makes a number of decisions on your behalf. For production servers, the manual repository method above is the recommended path because you stay in control of exactly what gets configured. Reserve the script for disposable or test environments.
How do you verify the Docker installation?
Once the install finishes, confirm the engine is present and can run a container.
“`bash
docker –version
sudo docker run hello-world “`
If `docker –version` prints a version string and `hello-world` downloads, runs, and prints its “Hello from Docker!” message, your installation is working. That `hello-world` run is a full end-to-end test: it confirms the daemon is running, the CLI can reach it, and Docker can pull and run an image.
What post-install steps should you do after installing Docker?
A working install is not a finished one. Two post-install steps separate a usable Docker host from a frustrating one.
Run Docker without sudo
By default the Docker daemon binds to a Unix socket owned by `root`, so every command needs `sudo`. Add your user to the `docker` group to run Docker commands directly.
“`bash
sudo groupadd docker # may already exist; harmless if it does sudo usermod -aG docker $USER
newgrp docker
docker run hello-world “`
Security note: Members of the `docker` group have root-equivalent privileges on the host, because they can mount any directory into a container. Only add trusted users.
Enable Docker to start on boot
On Ubuntu’s `systemd`, Docker is usually enabled automatically, but confirm it so containers come back after a reboot.
“`bash
sudo systemctl enable docker.service sudo systemctl enable containerd.service
sudo systemctl status docker “`
If you ever need to start, stop, or restart it manually, use `sudo systemctl start docker`, `stop`, or `restart`.
What are the first Docker commands to know?
With the engine installed and configured, these are the commands you will reach for first:
“`bash
docker ps docker ps -a
docker images
docker pull ubuntu:24.04
docker info “`
From here, `docker run`, `docker build`, and `docker compose up` cover most day-to-day work. If you are still building command-line fluency on the host itself, our is a useful companion.
For deeper context on the platform and how containers differ from virtual machines, see our explainers on and . Docker installation is just one piece of running a healthy Ubuntu box—for the full operational picture, our complete guide to managing Linux servers covers users, services, security, and monitoring end to end.
Run Docker on a server built for it. DarazHost Linux SSD VPS and dedicated servers—available with Ubuntu and other distributions—give you full root access to install Docker Engine and run containers on guaranteed, isolated resources. That is exactly the clean, controllable environment Docker is designed for, and our 24/7 support team is on hand if an install step ever snags. If you are spinning up your first container host, walks through the same process on a fresh DarazHost instance.
Frequently Asked Questions
Why shouldn’t I just use `apt install docker.io`? `docker.io` is Ubuntu’s bundled Docker package, and it is frequently several versions behind the current release. It also is not on Docker’s official update channel, so you can end up with outdated or inconsistent behavior. Installing `docker-ce` from Docker’s apt repository gives you the current version and the official upgrade path.
Can I install Docker Desktop on an Ubuntu server? You can, but you almost certainly should not. Docker Desktop is a GUI application that runs the engine inside a managed VM—it is built for developer laptops and workstations. On a headless server it adds overhead and complexity for no benefit. Install Docker Engine instead.
Do I need to install Docker Compose separately? No. The modern Compose plugin is included when you install `docker-compose-plugin` in the steps above, and you invoke it as `docker compose` (with a space). The old standalone `docker-compose` (with a hyphen) is deprecated.
Why does Docker still ask for sudo after I installed it? The Docker socket is owned by `root` by default. Add your user to the `docker` group (`sudo usermod -aG docker $USER`) and refresh your session with `newgrp docker` or by logging out and back in. After that, `docker` commands work without `sudo`.
Which Ubuntu versions does Docker Engine support? Docker Engine supports current LTS releases such as 24.04, 22.04, and 20.04, along with recent non-LTS releases. The repository setup above auto-detects your release codename, so the same commands work across supported versions.