I have a script which performs backup of several docker volumes during the night.

It starts by stopping the containers that use these volumes, then it creates a new container with all the volumes mounted and back them up with borg. Finally it restarts the containers.

Sometimes the scripts runs into weird issues, like a container can not start because its image or a network it uses is missing. Is it possible that docker daemon prunes them while my backup script is running? How can I disable it?

I could not see anything in daemon logs.

  • Please show us the script. Without knowing exactly what you're doing, it's not very possible for us to provide you with an answer.
    – user23588
    Dec 2 '20 at 10:16
  • I added a link to the script. This is only a jinja2 template but It is enough to understand what the script is doing.
    – Nautigsam
    Dec 3 '20 at 13:34

I noticed that you have the docker run command with --rm option. In the Docker docs it says:

If you set the --rm flag, Docker also removes the anonymous volumes associated with the container when the container is removed. This is similar to running docker rm -v my-container

Perhaps this is why the volumes are being deleted?


No, docker does not automatically prune networks or images. That is left to the user to implement with their own tooling or scripting. It is possible for docker-compose to remove networks, but only when running a docker-compose down, and that doesn't remove networks. You'll need to search your own environment to see what you have running that performs a prune.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.