- How to Upgrade Docker to the Latest Version on Ubuntu
How to Upgrade Docker to the Latest Version on Ubuntu
Step-by-step guide to replace Ubuntu's outdated Docker packages with the official repository

I recently had to upgrade Docker on an Ubuntu server that was still running an older apt-repo version. The default Ubuntu package sources are usually behind the official Docker releases, so if you want the latest features, bug fixes, and plugin updates, you need to switch to Docker’s official repository.
Here’s the exact process I used — works both for dev machines and headless servers.
1. Check the Latest Version
Before upgrading, see what the latest stable release is from the official Docker site:
That way you’ll know what you’re upgrading to and can confirm the install worked later.
2. Remove Old Docker Packages
Ubuntu may already have docker.io
or older docker-ce
versions installed. Remove them first so they don’t conflict:
sudo apt remove docker docker-engine docker.io containerd runc
This does not delete your images, containers, or volumes — they’re stored in /var/lib/docker
.
3. Add Docker’s Official Repository
Install prerequisites:
sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release
Add Docker’s GPG key:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Add the Docker apt repository:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
4. Install the Latest Docker
Update apt and install the latest Docker Engine, CLI, and plugins:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
If you ever want to see all available versions:
apt-cache madison docker-ce | awk '{print $3}'
5. Verify the Upgrade
Check versions to make sure everything matches what you saw in the release notes:
docker --version docker compose version docker buildx version
6. (Optional) Run Docker Without sudo
By default, Docker commands need sudo
. To run as your regular user:
sudo usermod -aG docker $USER
Then log out and back in (or disconnect/reconnect if using SSH).
Conclusion
Upgrading Docker on Ubuntu is mostly about replacing the default package source with the official Docker repository. Once that’s done, apt
will always pull the newest stable release along with the latest plugins like Compose and Buildx.
Now your environment is running the most recent Docker release — straight from the source — with all the latest features ready to go.
Thanks, Matija