Last active
June 26, 2021 22:48
-
-
Save bluebrown/a5312397df4f1fe03e0efe63975087fd to your computer and use it in GitHub Desktop.
Docker - call command from entrypoint.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine | |
COPY entrypoint.sh / | |
RUN chmod +x /entrypoint.sh | |
ENTRYPOINT [ "/entrypoint.sh" ] | |
CMD echo 'hello, captain!' | |
ENV FOO=bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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