Docker Installation on Ubuntu
Posted on September 7, 2023 (Last modified on November 8, 2025) • 6 min read • 1,074 wordsEverything starts with Docker - complete installation guide for Ubuntu Server with verification steps
Today we’re diving into the absolute foundation for modern homelab and server projects: Docker. Whether you want to run containers for web services, databases, monitoring tools, or entire development environments – everything starts with a clean Docker installation.
This article is intentionally brief and focused, because Docker installation is relatively straightforward. I’m following the official Docker documentation here, supplemented with some practical verification steps. Think of this post as the cornerstone for upcoming projects – the really exciting stuff comes after this!
Before we get started, make sure you meet the following prerequisites:
Before we install Docker fresh, let’s clean up first. If your system already has an old or unofficial Docker installation, we should remove it. This prevents conflicts between different Docker versions.
/var/lib/docker/.
Run the following command to uninstall all potentially existing Docker versions:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; doneIf none of these packages is installed, you’ll receive a corresponding message – that’s completely fine and means your system is “clean.”
Now we get to the core: installing Docker via the official apt repository. This method has the advantage that you always get the latest stable version of Docker and can conveniently apply updates via apt.
First, we update the package lists and install the necessary dependencies:
sudo apt-get updatesudo apt-get install ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringsThese packages are needed to securely add the Docker repository:
ca-certificates – Certificates for HTTPS connectionscurl – For downloading the GPG keyNow we add Docker’s official GPG key. This ensures that the downloaded packages are authentic:
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.ascNow we set up the official Docker repository:
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
sudo apt-get updateThis command creates the file /etc/apt/sources.list.d/docker.list with the correct repository URL for your Ubuntu version.
Before we install Docker, let’s verify that the repository is configured correctly and see which Docker version is available:
apt-cache policy docker-ce
docker-ce:
Installed: (none)
Candidate: 5:19.03.9~3-0~ubuntu-focal
Version table:
5:19.03.9~3-0~ubuntu-focal 500
500 https://download.docker.com/linux/ubuntu focal/stable amd64 PackagesPerfect! The output shows:
Installed: (none) – Docker is not yet installedCandidate: – The version that will be installedsudo apt-get install docker-ce=<VERSION>.
Now we can install Docker CE (Community Edition):
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginThis command installs:
docker-ce – The Docker Engine (the heart of it all)docker-ce-cli – The command-line toolscontainerd.io – The container runtimedocker-buildx-plugin – Advanced build systemdocker-compose-plugin – Docker Compose as a plugin (very handy!)Docker should start automatically after installation. To be safe, let’s verify this and enable automatic start on system boot:
sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2023-09-10 10:15:23 UTC; 2min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 12345 (dockerd)
Tasks: 8
Memory: 28.5M
CPU: 245ms
CGroup: /system.slice/docker.service
└─12345 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockGreat! The status shows active (running) – Docker is running. If the service is not active, start it manually:
sudo systemctl start dockerMake sure Docker starts automatically on system boot:
sudo systemctl enable dockerTo wrap things up, let’s run a small functional test. Docker provides a special test image for this purpose:
sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:4bd78111b6914a99dbc560e6a20eab57ff6655aea4a80c50b0c5491968cbc2e6
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.By default, you need sudo to execute Docker commands. For production use on servers this is often desired, but for your local homelab server it can be annoying.
If you want to execute Docker commands without sudo, add your user to the docker group:
sudo usermod -aG docker $USERnewgrp docker.
Test whether it works:
docker run hello-worldIf you can execute this command without sudo – congratulations, everything is perfectly set up!
docker group effectively have root privileges on the system, as they can start privileged containers. Use this only on trusted systems and don’t add unknown users to the docker group.
With Docker, you can now:
Everything starts with Docker – and you’ve just mastered that beginning.
In upcoming articles, we’ll explore Docker Compose, set up practical containers for your homelab (reverse proxy, monitoring, dashboards), and dive into advanced topics like networks and volumes.
Have fun experimenting with Docker!
Further Reading: