Add note that "hello-world" can run as an arbitrary user

This commit is contained in:
Tianon Gravi 2022-09-30 14:55:22 -07:00
parent 6dd87162d9
commit b84ae8ceba
2 changed files with 10 additions and 12 deletions

View File

@ -26,8 +26,8 @@ For more examples and ideas, visit:
$ docker images %%IMAGE%% $ docker images %%IMAGE%%
REPOSITORY TAG IMAGE ID SIZE REPOSITORY TAG IMAGE ID SIZE
hello-world latest feb5d9fea6a5 13256 hello-world latest feb5d9fea6a5 13.26kB
``` ```
%%LOGO%% %%LOGO%%
@ -35,3 +35,5 @@ hello-world latest feb5d9fea6a5 13256
# How is this image created? # How is this image created?
This image is a prime example of using the [`scratch`](https://hub.docker.com/_/scratch/) image effectively. See [`hello.c`](%%GITHUB-REPO%%/blob/master/hello.c) in %%GITHUB-REPO%% for the source code of the `hello` binary included in this image. This image is a prime example of using the [`scratch`](https://hub.docker.com/_/scratch/) image effectively. See [`hello.c`](%%GITHUB-REPO%%/blob/master/hello.c) in %%GITHUB-REPO%% for the source code of the `hello` binary included in this image.
Because this image consists of nothing but a single static binary which prints some text to standard output, it can trivially be run as any arbitrary user (`docker run --user $RANDOM:$RANDOM %%IMAGE%%`, for example).

View File

@ -15,20 +15,16 @@ echo '$ docker run %%IMAGE%%'
docker run --rm hello-world docker run --rm hello-world
echo echo
echo '$ docker images %%IMAGE%%' echo '$ docker images %%IMAGE%%'
{ docker image ls --format 'table {{ .Repository }}\t{{ .Tag }}\t{{ .ID }}\t{{ .VirtualSize }}' "$image:latest"
id="$(docker image inspect --format '{{ .Id }}' "$image:latest" | sed -r 's/^sha256:([a-f0-9]{12})[a-f0-9]+$/\1/')"
size="$(docker image inspect --format '{{ .VirtualSize }}' "$image:latest")"
echo $'REPOSITORY\tTAG\tIMAGE ID\tSIZE'
echo "$image"$'\tlatest\t'"$id"$'\t'"$size"
} | column -t -s$'\t'
echo '```' echo '```'
echo
echo '%%LOGO%%'
echo
cat <<'EOF' cat <<'EOF'
%%LOGO%%
# How is this image created? # How is this image created?
This image is a prime example of using the [`scratch`](https://hub.docker.com/_/scratch/) image effectively. See [`hello.c`](%%GITHUB-REPO%%/blob/master/hello.c) in %%GITHUB-REPO%% for the source code of the `hello` binary included in this image. This image is a prime example of using the [`scratch`](https://hub.docker.com/_/scratch/) image effectively. See [`hello.c`](%%GITHUB-REPO%%/blob/master/hello.c) in %%GITHUB-REPO%% for the source code of the `hello` binary included in this image.
Because this image consists of nothing but a single static binary which prints some text to standard output, it can trivially be run as any arbitrary user (`docker run --user $RANDOM:$RANDOM %%IMAGE%%`, for example).
EOF EOF