I installed Docker using the command `sudo apt-get install docker.io docker-compose -y` earlier this year on Debian, probably following a YouTube tutorial. I've realized that I'm on an older version, specifically Docker 20.10.24 and Docker Compose 1.29.2. Now, I have several services running in Docker, and I want to know how I can update to the latest version without losing any of my running services or containers. Any advice on the best approach?
4 Answers
Just to clarify, the method you used isn't actually an 'outdated' method; it's just the standard way for your Linux distribution to install Docker.
Check out the official Docker docs on uninstalling old versions [here](https://docs.docker.com/engine/install/debian/#uninstall-old-versions). If you're following good practices and all your containers are defined with compose files and stored in volumes on the host, you can uninstall the current Docker and Docker Compose and then install them fresh, the right way. Just remember to back up anything important first!
You can run `curl -fsSL https://get.docker.com | bash` to update Docker. Just be aware that there's a risk involved with running scripts you find online. If you want to be extra cautious, download the script, review it first, and then execute it after you're sure it's safe!
Running scripts from the internet can be risky. That script is pretty long, almost 700 lines! You'd need to verify all of it for safety. Another option is to add Docker's official APT repository and use `apt-get` to install updates, which provides some extra security.
Here's a quick snapshot of your current version, if you're curious about it!

Great advice! I'm planning to do a full disk image backup before starting the update. Better safe than sorry!