Learn to create a Docker image from a running container using docker container commit for rapid prototyping or debugging changes.
In this guide, you’ll learn how to create a Docker image from a running container using docker container commit. This technique can be useful for rapid prototyping or debugging changes without writing a Dockerfile. For production-grade images, you should still prefer the Dockerfile approach to ensure repeatability and version control.
Enter the container and update the default web page
Copy
Ask AI
docker exec -it httpd bashroot@container:/# cat > /usr/local/apache2/htdocs/index.html <<EOFWelcome to my custom web applicationEOFroot@container:/# exit
Commit the container state to a new image
Copy
Ask AI
docker container commit -a "Ravi" httpd customhttpd
Verify the new image
Copy
Ask AI
docker image lsREPOSITORY TAG IMAGE ID CREATED SIZEcustomhttpd latest adac0f56a7df 5 seconds ago 138MBhttpd latest 417af7dc28bc 8 days ago 138MB