Skip to content

Instantly share code, notes, and snippets.

@bluebrown
Last active June 26, 2021 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluebrown/a5312397df4f1fe03e0efe63975087fd to your computer and use it in GitHub Desktop.
Save bluebrown/a5312397df4f1fe03e0efe63975087fd to your computer and use it in GitHub Desktop.
Docker - call command from entrypoint.sh
FROM alpine
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
CMD echo 'hello, captain!'
ENV FOO=bar
#!/bin/sh
# exit on first error (opposite of default shell behavior)
set -e
# print executed commands. Useful for debugging. Be careful to not expose secrets!
# set -x
# perform some work and access the env variables that are defined by docker
echo "$FOO"
# the CMD is accessbile via $@
# you can just execute it:
#
# exec $@
#
# or use it like a real docker entrypoint
# i.e.
printenv | grep $@
$ docker build -t test .
$ docker run test foo
bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment