On one of our servers, there is a demo application installed for our customers.
which consists of two docker images,
is managed by a
As the customers are able to change the data, the containers and the attached volume are torn down every night, and then rebuilt.
Monitoring made me aware, that we are running low on disk space.
Turns out the volumes do not get deleted with the current cronjob:
docker-compose down && docker-compose up -d
As a quick fix, I ran a
docker volumes ls, followed by a
docker volume prune.
This deletes all unused local volumes.
In order to use this as an unattended command,
you need to append the
otherwise you get prompted for confirmation.
As I am pretty new to Docker land, I looked around for other solutions.
One answer on StackOverflow suggests to use
docker-compose -rm -fsv,
force, ie no confirmation necessary
stopthe containers, if necessary
vremoves anonymous volumes, attached to the containers
At the end, I settled for
docker-compose down -v,
vremoves both named, and anonymous volumes, attached to the container
So my new cronjob looks like
docker-compose down -v && docker-compose up -d
I keep my fingers crossed - tomorrow I will now whether this worked out :-)