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:

  • Missing package
  • Can not pull docker image from private repo when using Minikube
  • Custom Container for hosting OpenLDAP in Bluemix
  • Docker with Django/PostgreSQL
  • Using nginx as a proxy to to java web servlet
  • How to assign static public IP to docker 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.

  • Installing libLAS on docker python - No such file or directory
  • docker-compose for mediawiki with data only containers
  • Docker-compose failing to run a jar file but works with Dockerfile
  • Cannot publish any docker containers
  • django postgresql password authentication failed for user
  • Connecting from a docker container to the host?
  • 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.