Automating docker commit and push
We have application running in a docker container. We would like to save backup of container every day. And I think docker commit and docker push is one of the option to take backup and push the new image into docker hub.
But this has to be done manually.
Does docker provides a way to do this (commit and push) automatically? Or is there any open source tool to do that?
Or do we need to write scripts and add it in cron job?
I came through this SO. But the answer is based on docker events. It is little complicated for my job. Is there any simple way?
One Solution collect form web for “Automating docker commit and push”
I would recommend you to not do that :). This would result indeed in snapshots, but you endup with a long running container that can’t be restarted from origin from the snapshot. Also this will result in bigger and bigger snapshots over time.
A better way to approach this would be to control your state and either use volumes and simply do a cron job to tar/backup that volume (you can take a look at at https://github.com/tutumcloud/dockup to make it automatic).
An other way would be to still control your state and periodically perform a
docker cp to extract your state.
That way your container itself is stateless and can be reused easily from the original point or any point in time via that backup. It simplified a lot upgrades.
If you don’t control your state, then you are right, commit/push would be a solution, but I’d recommend to stop the container and restart from the commit version. That way, next time, the snapshot will contains only the diff from the previous one. To do so, you will need to write your own script and add it to a cronjob.