Skip to main content
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.

Overview

Typically, custom images are built with a Dockerfile:
Alternatively, you can:
  1. Launch a container from a base image (e.g., httpd).
  2. Modify files or install packages inside the container.
  3. Commit the container’s state as a new image.
The docker commit workflow is not recommended for production systems. Use a Dockerfile for maintainability, readability, and versioning.

When to Use docker commit

Step-by-Step Example

  1. Run an httpd container in detached mode
  2. Enter the container and update the default web page
  3. Commit the container state to a new image
  4. Verify the new image

Comparison: Dockerfile vs. docker commit

References

Watch Video