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:

  • Docker maven plugin ClientProtocolException (Windows 10 using Docker Toolbox)
  • How to get the status of Docker Image Tag that lies in a private registry
  • Where is the new docker hub api documentation?
  • How do I run a command on an already existing Docker container?
  • Opening Port in Docker Container
  • Docker Wildfly Image with 32 bit Java
    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.

  • Mount non-existing host directory into non-root container
  • Docker and nodemcu-build. Excited but unable to run it
  • Not all services are registered in Consul with Registrator
  • Precompiled assets absent in the docker image
  • Error response from daemon: Cannot start container
  • How do I make a standalone application out of a Docker container?
  • 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.

    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.