Can Docker Autonomously Restart Containers and Commit Changes with New Image Tag?

I am using Docker for my deployment and as it stands I use Docker-Compose (.yml file) to launch ~6 containers simultaneously. Each image within the Compose file is locally found (no internet connection within deployment environment).

As it stands the steps my deployment takes are as follows:

  • Using a volume with a redmine docker container in Bluemix
  • Docker: how to use container to replace real smtp server?
  • Docker container has trouble mounting volume with Jenkins
  • How to inspect a running Docker container
  • Optimising cargo build times in docker
  • How to start Phoenix by using PostgeSQL through container?
    1. Run docker-compose up (launches 6 containers from local images such as image1:latest, image2:latest, etc. using the images with the “latest” tag)
    2. When exited/stopped, I have 6 stopped containers. Manually restart each of the six stopped containers (docker start xxx)
    3. Manually commit each re-started container (docker commit xxx)
    4. Manually re-tag each of the previous generation images incrementally (image1:latest -> image1:version1, image1:version2, etc.) and manually delete the image containing the “latest” tag
    5. Manually tag each of the committed containers (which are now images) with the “latest” tag (image1:latest)

    This process is rather user-involved and our deployment requires the user involvement to only be run the “docker-compose up” command then shutting down/stopping Docker-Compose.

    The required end goal is to have a script, or Docker, take care of these steps by itself and end up with different generations of images (image1:version1, image1:version2, image1:latest, etc.).

    So, my question is, how would I go about creating a script (or have Docker do it) where the script (or Docker) can autonomously:

    • Restart the stopped containers upon stopping/exiting of Docker-Compose
    • Commit the restarted containers
    • Re-tag the previous images with latest tags to an incremented version# (image1:version1, image1:version2, etc.) then delete the previous image1:latest image
    • Tag the newly committed restarted containers (which are now images) with the “latest” tag

    This is a rather lengthy and intensive question to answer, but I would appreciate any help with any of the steps required to accomplish my task. Thank you.

  • How to share a Laravel app codebase in a Docker container while preserving permissions?
  • docker-compose - how to escape environment variables
  • Django migrations with Docker on AWS Elastic Beanstalk
  • Docker-Compose won't volume my php.ini file
  • Launching multiple Docker containers with supervisor
  • Docker on the mac separates internal and external file ownerships; not so on linux
  • One Solution collect form web for “Can Docker Autonomously Restart Containers and Commit Changes with New Image Tag?”

    The watchtower project tries to address this.

    https://github.com/CenturyLinkLabs/watchtower

    It auto restarts a running container when a base image is updated.

    It is also intelligent so, for example, when in needs to restart a container that is linked to other containers, it does so without destroying the links.

    I’ve never tried it but worth a shot!

    Let us know how it goes. I’m gonna favourite this question as it sounds a great idea.

    PS If watchtower proves a pain and you try to do this manually then …

    docker inspect
    

    is your friend since it gives you loads of info about containers and images. Allowing you to determine current status.

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