0

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.

2
  • 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. Commented Dec 2, 2020 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. Commented Dec 3, 2020 at 13:34

2 Answers 2

1

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?

0

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.