From b84ae8ceba69b2a36ed8c73c85964561a24e0385 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 30 Sep 2022 14:55:22 -0700 Subject: [PATCH] Add note that "hello-world" can run as an arbitrary user --- hello-world/content.md | 6 ++++-- hello-world/update.sh | 16 ++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hello-world/content.md b/hello-world/content.md index 7a610fd1e..fc79d8d7f 100644 --- a/hello-world/content.md +++ b/hello-world/content.md @@ -26,8 +26,8 @@ For more examples and ideas, visit: $ docker images %%IMAGE%% -REPOSITORY TAG IMAGE ID SIZE -hello-world latest feb5d9fea6a5 13256 +REPOSITORY TAG IMAGE ID SIZE +hello-world latest feb5d9fea6a5 13.26kB ``` %%LOGO%% @@ -35,3 +35,5 @@ hello-world latest feb5d9fea6a5 13256 # 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. + +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). diff --git a/hello-world/update.sh b/hello-world/update.sh index 505ed6490..093a50fdd 100755 --- a/hello-world/update.sh +++ b/hello-world/update.sh @@ -15,20 +15,16 @@ echo '$ docker run %%IMAGE%%' docker run --rm hello-world echo echo '$ docker images %%IMAGE%%' -{ - 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' +docker image ls --format 'table {{ .Repository }}\t{{ .Tag }}\t{{ .ID }}\t{{ .VirtualSize }}' "$image:latest" echo '```' -echo -echo '%%LOGO%%' - -echo cat <<'EOF' + +%%LOGO%% + # 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. + +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