How can I run a docker container and commit the changes once a script completes?

后端 未结 4 2080
萌比男神i
萌比男神i 2021-02-14 22:57

I want to set up a cron job to run a set of commands inside a docker container and then commit the changes to the docker image. I\'m able to run the container as a daemon and ge

4条回答
  •  我寻月下人不归
    2021-02-14 23:21

    Try this if you want an auto commit for all which are running. Put this in a cron or something, if this helps

    #!/bin/bash
    for i in `docker ps|tail -n +2|awk '{print $1}'`; do docker commit -m "commit new change" $i; done
    

提交回复
热议问题