Keeping Docker Engine and Compose updated brings security fixes, performance improvements, and compatibility with newer image features. This guide covers updating safely without disrupting running containers.
Prerequisites
- Docker Engine installed via the official repository
- Root or sudo access
Step 1 — Check Current Versions
docker --version
docker compose version
Step 2 — Refresh Package Information
sudo apt update
Step 3 — Upgrade Docker Packages
sudo apt install --only-upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
Step 4 — Restart the Docker Service
sudo systemctl restart docker
Restarting the Docker daemon does not stop containers configured with a restart policy — they typically resume automatically, but briefly interrupt network connections during the restart.
Step 5 — Verify
docker --version
docker compose version
docker ps
Step 6 — Update Your Application Images
Updating Docker itself does not update the images your containers run. Pull the latest versions separately:
cd /path/to/your/project
docker compose pull
docker compose up -d
Compose will recreate only the containers whose images actually changed.
Step 7 — Clean Up Old Images and Unused Resources
docker system df
docker image prune -a
docker volume prune
docker network prune
docker image prune -a removes all unused images — confirm you don't need any of them cached locally before running it.
Common Errors
Packages held back:
sudo apt update
sudo apt full-upgrade -y
Containers don't start after update — check logs:
docker compose logs
Best Practices
- Create a snapshot or backup before major version updates on production systems
- Update during a scheduled maintenance window
- Review Docker's release notes for breaking changes before major upgrades
- Update images and Docker Engine on a regular schedule, not just reactively
FAQ
Will updating Docker delete my containers or volumes?
No — updating the Docker Engine package does not remove existing containers, images, or volumes.
How often should I update Docker?
Check monthly at minimum, and apply security-related releases promptly.
Related Articles
- How to Install Docker Engine on Ubuntu & Debian
- Docker Compose Troubleshooting: Common Errors & Fixes
- Docker Security Best Practices
