MongoDB in Docker - backup database on container shutdown
<p>I'm trying to setup docker-compose with Node and MongoDB. In combination with the official Mongo container I'm using a dedicated container (<a href="https://github.com/tutumcloud/mongodb-backup" rel="nofollow noreferrer">mongodb-backup</a>) for continuous backups of the database and an initial restore at startup.</p>

<p>My problem is how to trigger a backup in case of a graceful shutdown by <code>docker-compose stop</code>.<br>
Therefore it's necessary to shut down the Node container at first to guarantee no process is writing to the database. Then backup the database and finally shutdown the mongodb and mongodb-backup conatainers.</p>

<p>This <a href="https://github.com/twittwer/mongodb-backup/tree/docker-compose" rel="nofollow noreferrer">repository</a> contains my docker-compose setup of mongodb and mongodb-backup.</p>

<p>Does anyone have an idea how to implement this?</p>