Reputation: 12392
How can I show the full command in the third column (CREATED BY) in the docker history
output?
$ $ docker history python
IMAGE CREATED CREATED BY SIZE COMMENT
69ee9abe2bda 5 weeks ago CMD ["python3"] 0B buildkit.dockerfile.v0
<missing> 5 weeks ago RUN /bin/sh -c set -eux; wget -O get-pip.p… 10MB buildkit.dockerfile.v0
<missing> 5 weeks ago ENV PYTHON_GET_PIP_SHA256=22b849a10f86f5ddf7… 0B buildkit.dockerfile.v0
...
The CREATED BY
is truncating/abbreviating the commands which makes it hard to reconstruct the original Dockerfile. How do I get the full CREATED BY
commands?
Upvotes: 63
Views: 41154
Reputation: 4777
Use the docker history --no-trunc
option to show the full command.
Upvotes: 85
Reputation: 3113
I needed to see the full build history without truncated build steps in a tabular format for debugging purposes. The Docker Docs examples are often incomplete (or non-existent). The accepted answer by @Alassane_Hdiaye can work, but throws an error if used in the wrong place. After a couple tries, I got the GoLang template table formatter to produce the result I needed.
The Docker GoLang template --format
option works with docker history
, but must be entered AFTER --format
, because it modifies --format
, NOT docker history
. The docker history
command takes only 1 argument. The --format
option changes the output of docker history
, and --no-trunc
modifies the --format
option.
The command sequence must be
docker history <image-id> --format <GoLang template spec> --no-trunc
The --no-trunc
option follows --format
on the command line, because it modifies the --format
option.
So for the fully history in a tabular format:
docker history <image-id> --format "table{{.ID}}, {{.CreatedBy}}" --no-trunc
The output is messy, because Dockerfile RUN commands can wrap many lines.
So pipe the result to a CSV file and open it in Excel (for lack of a better table viewer).
docker history <image-id> --format "table{{.ID}}, {{.CreatedBy}}" --no-trunc > image-id-history.csv
So now I can see complete build instructions in Excel without truncation.
As a side note, Docker history
does not output RUN and other dockerfile build keywords, but these can be inferred. But at least full commands from the complete history are available.
Upvotes: 20