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?

  • Parsing a string to an array output from command line
  • Docker Containers and IO Operations & Network
  • VOLUME command in docker image is using custom-volume driver
  • Unable to launch tomcat using docker
  • Deis docker image deploy
  • kali linux docker image build script failed - syntax error near unexpected token `;&' [closed]
  • 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?

  • Does it make any difference to include or omit :latest when pulling a Docker image?
  • Mystery of the Restarting Docker Container
  • How do a see the “ancestor tree” of a docker-compose file
  • Is that possible to get image ID from Docker Registry V2?
  • Docker stack “--force-recreate” in swarm mode using compose file
  • tomcat7 session replication doesn't work under docker swarm mode
  • 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 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.