Committing images from running containers

You should build your images from a Dockerfile. That's a repeatable process in a script that can be stored in source control for versioning, comparison, and authorization. But there are some applications that need additional setup steps after the application is deployed, and those steps need to be executed manually.

Jenkins is a good example of this. You can automate the plugin installation with Jenkins, but it requires an additional download and some scripting of the Jenkins API. Plugin dependencies are not always resolved when you install that way, so it can be safer to manually set up the plugins and verify the deployment. Once you've done that, you can persist the final setup by committing the container, which generates a new Docker image from the container's current state.

On Windows, you need to stop containers to commit them, and then run docker container commit, giving the name of the container and the new image tag to create:

> docker container stop jenkins
jenkins

> docker container commit jenkins dockeronwindows/ch10-jenkins:2e-final
sha256:96dd3caa601c3040927459bd56b46f8811f7c68e5830a1d76c28660fa726960d

For my setup, I've committed Jenkins and Gogs and I have a Docker Compose file to configure them, together with the registry container. These are infrastructure components, but this is still a distributed solution. The Jenkins container will access the Gogs and registry containers. The services all have the same SLA, so defining them in a Compose file lets me capture that and start all the services together.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.237.164