From 058f7dfa01821913ac4b468d705a2da9affe5ee0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 17 Nov 2022 14:17:23 +0100 Subject: [PATCH] docs: docker inspect --size Signed-off-by: David Karlsson Signed-off-by: Sebastiaan van Stijn (cherry picked from commit e064f893a6ea2772f7db03a4a41808fa859959cf) Signed-off-by: Sebastiaan van Stijn --- docs/reference/commandline/inspect.md | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/reference/commandline/inspect.md b/docs/reference/commandline/inspect.md index 9d94dc29fc83..777a6e20e554 100644 --- a/docs/reference/commandline/inspect.md +++ b/docs/reference/commandline/inspect.md @@ -49,6 +49,35 @@ The following example inspects a _volume_ named "myvolume" $ docker inspect --type=volume myvolume ``` +### Inspect the size of a container (-s, --size) + +The `--size`, or short-form `-s`, option adds two additional fields to the +`docker inspect` output. This option only works for containers. The container +doesn't have to be running, it also works for stopped containers. + +```console +$ docker inspect --size mycontainer +``` + +The output includes the full output of a regular `docker inspect` command, with +the following additional fields: + +- `SizeRootFs`: the total size of all the files in the container, in bytes. +- `SizeRw`: the size of the files that have been created or changed in the + container, compared to it's image, in bytes. + +```console +$ docker run --name database -d redis +3b2cbf074c99db4a0cad35966a9e24d7bc277f5565c17233386589029b7db273 +$ docker inspect --size database -f '{{ .SizeRootFs }}' +123125760 +$ docker inspect --size database -f '{{ .SizeRw }}' +8192 +$ docker exec database fallocate -l 1000 /newfile +$ docker inspect --size database -f '{{ .SizeRw }}' +12288 +``` + ## Examples ### Get an instance's IP address