# docker commit: Create an Image from a Container

> How docker commit works: snapshotting a container into a new image, setting CMD, and why Dockerfiles beat commit in CI.

Source: https://latchkey.dev/learn/command-reference/docker-commit-command  
Updated: 2026-06-25

Snapshot a container into a new image - handy for debugging, not for builds.

docker commit creates a new image from a container current state. This page covers the flags and why reproducible builds should use a Dockerfile instead.

## What it does

docker commit captures the writable layer of a container (changes since it started) as a new image layer, optionally setting config like CMD. Unlike a Dockerfile build, the result is opaque and not reproducible.

## Common usage

```Terminal
docker commit mycontainer myimage:debug
docker commit -m "added patch" -a "me" mycontainer myimage:patched
docker commit --change "CMD [\"node\",\"server.js\"]" mycontainer myapp:snap
```

## Common errors in CI

commit is fine for capturing a broken container to inspect later, but in CI prefer a Dockerfile: a committed image cannot be rebuilt from source, has no cache benefits, and hides what changed. If the new image "does nothing", you likely did not carry CMD over - set it with --change at commit time.

## FAQ

### docker commit: Create an Image from a Container?

docker commit creates a new image from a container current state. This page covers the flags and why reproducible builds should use a Dockerfile instead.

### What it does?

docker commit captures the writable layer of a container (changes since it started) as a new image layer, optionally setting config like CMD. Unlike a Dockerfile build, the result is opaque and not reproducible.

### Common errors in CI?

commit is fine for capturing a broken container to inspect later, but in CI prefer a Dockerfile: a committed image cannot be rebuilt from source, has no cache benefits, and hides what changed. If the new image "does nothing", you likely did not carry CMD over - set it with --change at commit time.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
