Skip to content

Commit 894e2a4

Browse files
authored
Merge pull request #2209 from infosiftr/hello-world-arbitrary-user
Add note that "hello-world" can run as an arbitrary user
2 parents 5fa6462 + b84ae8c commit 894e2a4

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

hello-world/content.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ For more examples and ideas, visit:
2626

2727

2828
$ docker images %%IMAGE%%
29-
REPOSITORY TAG IMAGE ID SIZE
30-
hello-world latest feb5d9fea6a5 13256
29+
REPOSITORY TAG IMAGE ID SIZE
30+
hello-world latest feb5d9fea6a5 13.26kB
3131
```
3232

3333
%%LOGO%%
3434

3535
# How is this image created?
3636

3737
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.
38+
39+
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).

hello-world/update.sh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@ echo '$ docker run %%IMAGE%%'
1515
docker run --rm hello-world
1616
echo
1717
echo '$ docker images %%IMAGE%%'
18-
{
19-
id="$(docker image inspect --format '{{ .Id }}' "$image:latest" | sed -r 's/^sha256:([a-f0-9]{12})[a-f0-9]+$/\1/')"
20-
size="$(docker image inspect --format '{{ .VirtualSize }}' "$image:latest")"
21-
echo $'REPOSITORY\tTAG\tIMAGE ID\tSIZE'
22-
echo "$image"$'\tlatest\t'"$id"$'\t'"$size"
23-
} | column -t -s$'\t'
18+
docker image ls --format 'table {{ .Repository }}\t{{ .Tag }}\t{{ .ID }}\t{{ .VirtualSize }}' "$image:latest"
2419
echo '```'
2520

26-
echo
27-
echo '%%LOGO%%'
28-
29-
echo
3021
cat <<'EOF'
22+
23+
%%LOGO%%
24+
3125
# How is this image created?
3226
3327
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.
28+
29+
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).
3430
EOF

0 commit comments

Comments
 (0)