From 218a842efb7fc91e4c48de592665169dcafb15b9 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 26 Apr 2026 11:15:58 +0800 Subject: [PATCH] docs: clarify repeated ENV changes with docker commit Signed-off-by: Codex --- docs/reference/commandline/container_commit.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/reference/commandline/container_commit.md b/docs/reference/commandline/container_commit.md index 6aab8df4d0aa..cf09ab384733 100644 --- a/docs/reference/commandline/container_commit.md +++ b/docs/reference/commandline/container_commit.md @@ -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. + +```console +$ docker commit \ + --change "ENV DEBUG=true" \ + --change "ENV LOG_LEVEL=debug" \ + c3f279d17e0a svendowideit/testimage:version3 + +$ docker inspect -f "{{ .Config.Env }}" svendowideit/testimage:version3 + +[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