Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/reference/commandline/container_commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ $ docker inspect -f "{{ .Config.Env }}" f5283438590d
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
```

You can repeat `--change` to apply multiple Dockerfile instructions in the same commit. When you use repeated `ENV`
instructions, each one updates the named variable while leaving the rest of the environment intact.

Comment on lines +82 to +84
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description marks this as closing #169, but the linked issue also asks about deleting ENV entries, overwriting all ENV, and the alternative bracket/JSON-array syntax. As written, this section only covers repeating --change / additive ENV behavior; consider expanding the docs to cover the other questions or changing the PR metadata so the issue isn't closed prematurely.

Copilot uses AI. Check for mistakes.
```console
$ docker commit \
--change "ENV DEBUG=true" \
--change "ENV LOG_LEVEL=debug" \
c3f279d17e0a svendowideit/testimage:version3

$ docker inspect -f "{{ .Config.Env }}" svendowideit/testimage:version3
Comment on lines +83 to +91
Copy link

Copilot AI Apr 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example reuses the svendowideit/testimage:version3 tag from the prior examples in this page and repeats ENV DEBUG=true, which makes the flow harder to follow if a reader runs the commands sequentially (it overwrites the tag and doesn't clearly demonstrate "update" vs "add"). Consider using a new tag (e.g., version3b) and/or setting the same variable twice with different values to demonstrate that later ENV values win while preserving the rest of the environment.

Suggested change
instructions, each one updates the named variable while leaving the rest of the environment intact.
```console
$ docker commit \
--change "ENV DEBUG=true" \
--change "ENV LOG_LEVEL=debug" \
c3f279d17e0a svendowideit/testimage:version3
$ docker inspect -f "{{ .Config.Env }}" svendowideit/testimage:version3
instructions for the same variable, later values override earlier ones while leaving the rest of the environment intact.
```console
$ docker commit \
--change "ENV DEBUG=false" \
--change "ENV DEBUG=true" \
--change "ENV LOG_LEVEL=debug" \
c3f279d17e0a svendowideit/testimage:version3b
$ docker inspect -f "{{ .Config.Env }}" svendowideit/testimage:version3b

Copilot uses AI. Check for mistakes.

[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true LOG_LEVEL=debug]
```

### Commit a container with new `CMD` and `EXPOSE` instructions

```console
Expand Down
Loading