Docker Engine 29 reference · Images
docker history Command (Docker CLI)
Show the layers of an image and the instruction that created each, with sizes, to find what makes it big.
Docker Engine 29
Syntax
docker history [OPTIONS] IMAGE
Parameters
| Parameter | Description |
|---|---|
--no-trunc |
Show full instructions. |
--format TEMPLATE |
e.g. '{{.Size}} {{.CreatedBy}}'. |
Examples
printf 'FROM alpine:3.24\nRUN head -c 3000000 /dev/zero > /big.bin\nCMD ["ls", "-l", "/big.bin"]\n' > Dockerfile
docker build -q -t rc-ref-hist:1 . > /dev/null
docker history rc-ref-hist:1 --format '{{.Size}}\t{{.CreatedBy}}' | head -3 | cut -c1-70
docker image rm rc-ref-hist:1 > /dev/null
Output
0B CMD ["ls" "-l" "/big.bin"] 3.01MB RUN /bin/sh -c head -c 3000000 /dev/zero > /… 0B CMD ["/bin/sh"]
Run this on your computer — see “Get Started” for setup.
printf 'FROM alpine:3.24\nARG TOKEN\nRUN test -n "$TOKEN"\n' > Dockerfile
docker build -q --build-arg TOKEN=s3cr3t -t rc-ref-hist:2 . > /dev/null
echo "build arg visible in history: $(docker history --no-trunc rc-ref-hist:2 | grep -c s3cr3t)"
docker image rm rc-ref-hist:2 > /dev/null
Output
build arg visible in history: 2
Run this on your computer — see “Get Started” for setup.
Related
docker build· Build an image from a Dockerfile and a build context, with tags, build arguments, secrets, targets and platforms.docker image ls· List local images with repository, tag, ID and size; filter dangling images and format the output.- Build Arguments and Environment Variables · tutorial