Last active
August 29, 2015 14:17
-
-
Save RichardBronosky/570e00d5d18ee4e69eca to your computer and use it in GitHub Desktop.
Your Dockerfile ENTRYPOINT's dirty little secret.
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 ubuntu | |
# Works the same on Centos too if you want to try it. ;-) | |
# "Shell Form" | |
# Don't do this. it fails to accept arguments from the docker cli | |
ENTRYPOINT cat | |
# "Exec Form" | |
# This is what you want. Even if the "Shell Form" seems to work for you. (See the transcript below.) | |
ENTRYPOINT ["cat"] | |
# NOTE: According to https://docs.docker.com/reference/builder/#entrypoint | |
# "Only the last ENTRYPOINT instruction in the Dockerfile will have an effect." |
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 myimage . | |
echo -ne 'asdf\n\nqwer\n\n' | docker run -i myimage -e |
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
## Shell Form output (the ENTRYPOINT does not receive the "-e" argument) | |
echo -ne 'asdf\n\nqwer\n\n' | docker run -i myimage -e | |
asdf | |
qwer | |
## Exec Form output (the ENTRYPOINT receives the "-e" argument) | |
echo -ne 'asdf\n\nqwer\n\n' | docker run -i myimage -e | |
asdf$ | |
$ | |
qwer$ | |
$ | |
## Rationale | |
~# echo -ne 'asdf\n\nqwer\n\n' | cat -e | |
asdf$ | |
$ | |
qwer$ | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment