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:

  • How to run Alfresco Bundled Installer on Docker?
  • Slow DNS resolution inside docker container
  • Consul running on Docker HTTP health check returns “connection reset by peer”
  • ASP.NET 5 and Docker error: /bin/sh: [dnx,: command not found
  • How does ENTRYPOINT Docker directive react when extending images
  • Docker Python issue
    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.

  • AWS EB should create new instance once my docker reached its maximum memory limit
  • Max Depth Exceeded error while creating a Docker image
  • How to detect a docker daemon port
  • Docker: Granting access to linked mysql container
  • Docker-machine : How to exec an ssh command correctly?
  • org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: []
  • 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.