run.sh 747 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. set -eo pipefail
  3. image="$1"
  4. # test that we can override the CMD with echo
  5. # https://github.com/docker-library/official-images/blob/d28cb89e79417cac50c2a8ae163a9b3b79167f79/README.md#consistency
  6. hello="world-$RANDOM-$RANDOM"
  7. # test first with --entrypoint to verify that we even have echo (tests for single-binary images FROM scratch, essentially)
  8. if ! testOutput="$(docker run --rm --entrypoint echo "$image" "Hello $hello" 2>/dev/null)"; then
  9. echo >&2 'image does not appear to contain "echo" -- assuming single-binary image'
  10. exit
  11. fi
  12. [ "$testOutput" = "Hello $hello" ]
  13. # now test with normal command to verify the default entrypoint is OK
  14. output="$(docker run --rm "$image" echo "Hello $hello")"
  15. [ "$output" = "Hello $hello" ]