Update Docker to Latest Version on Ubuntu
Remove outdated packages, add Docker's official repo, and fix 'client version too old' errors

🐳 Docker & DevOps Implementation Guides
Complete Docker guides with optimization techniques, deployment strategies, and automation prompts to streamline your containerization workflow.
Related Posts:
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.
If you want to completely clean up and remove volumes that might be in use, check out our guide on deleting Docker volumes safely.
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
Now that you have the latest Docker installed, consider setting up development containers if you're on a dev machine. Our guide to configuring VSCode dev containers shows how to create isolated, reproducible development environments.
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).
If you run into permission issues even after this step, our detailed guide on fixing permission denied errors in Docker covers bind mounts, USER directives, and CI/CD scenarios.
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.
For Docker configuration and optimization, check out our guides on configuring environment variables in Docker Compose, exposing containers with Cloudflare Tunnel (no Nginx needed), or automating SSL certificate renewal with Certbot.
Once you're ready for production, our complete guide to deploying React Vite apps with Docker covers VPS setup, Nginx configuration, and SSL certificates.
Now your environment is running the most recent Docker release — straight from the source — with all the latest features ready to go.
Thanks, Matija


