docker commit Explained
What docker commit does, with an example.
Published November 9, 2026
docker commit creates a new image from a container's current state. It is handy for quick experiments but is not a repeatable way to build images.
How it works
Changes made inside a container (installed packages, edited files) are captured as a new layer.
Prefer a Dockerfile so builds are documented and reproducible.
Try it
docker commit web web-snapshot:1
sha256:9f8e7d6c...
docker images web-snapshot
Practical examples
Snapshot a container
docker commit web web-snapshot:1With message and author
docker commit -m "added config" -a "Ada" web web:v2Run the snapshot
docker run -it web-snapshot:1 bashBetter: Dockerfile
FROM nginx
COPY nginx.conf /etc/nginx/nginx.confCommon mistakes
- Using commit as the build process (not reproducible).
- Committing secrets and large caches.
- Losing track of what changed.
Key takeaways
- docker commit creates a new image from a container's current state.
- Run docker <command> --help for all options.
- Clean up unused resources regularly.
FAQ
Commit vs build?
Build is repeatable from a Dockerfile; commit captures ad-hoc state.
Where can I see all options?
Run the command with --help.