update.sh 1000 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. set -Eeuo pipefail
  3. image="${1:-hello-world}"
  4. echo hello-world "$image" | timeout 5s xargs -P2 -n1 docker pull &> /dev/null || exit 0
  5. exec > "$(dirname "$(readlink -f "$BASH_SOURCE")")/content.md"
  6. echo '# Example output'
  7. echo
  8. echo '```console'
  9. echo '$ docker run %%IMAGE%%'
  10. docker run --rm hello-world
  11. echo
  12. echo '$ docker images %%IMAGE%%'
  13. docker image ls --format 'table {{ .Repository }}\t{{ .Tag }}\t{{ .ID }}\t{{ .VirtualSize }}' "$image:latest"
  14. echo '```'
  15. cat <<'EOF'
  16. %%LOGO%%
  17. # How is this image created?
  18. 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.
  19. 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).
  20. EOF