I installed docker using the command sudo apt get install docker.io docker-compose -y at the start of the year on Debian (must have followed a YouTube guide) and have since learned that this is an old way of installing it as it’s on version 20.10.24 of docker and 1.29.2 of docker compose.
The current way with docker-ce would require me to uninstall docker.io and docker-compose before running the current script.
I have many containers running in docker now and I want to update docker. How can I do this without losing the services/containers I have running?
If you share commands, please mark them as code or code-block so become easier to spot.
You can check the output of docker info --format ‘{{.DockerRootDir}}’, it should return /var/lib/docker
If you uninstall the docker.io package, the folder will be retained. If you install docker-ce (=vanila docker) from dockers repos. It should use the same data dir.
docker.io is an opinionated packaging of docker from the distro maintainers. docker-ce will high likely be able to work with the existing data, so that images, containers, networks and such will continue to be available/work.
Potential problems that could come to mind:
docker.io might have modified things under the hood that they are not 100% compatible with vanilla docker
the version gap between docker.io and docker-ce might be too big to migrate the configurations to the new version
docker-ce might pick up a different storage driver than docker.io did
Check docker info --format ‘{{.Driver}}’ on docker.io and verify after migrating to docker-ce that it stayed the same, otherwise configure it in /etc/docker/daemon.json
I feel there is a low risk in something going wrong.
If you feel uncertain create a backup of your /var/lib/dockerfolder, after removing the docker.io package/before installing the docker-ce package.
Update: I updated your post and highlighted packages and commands as code.