Last active
August 31, 2018 04:25
-
-
Save AlecTaylor/0f38ba61ed866dd5187c06f67e6f8ed4 to your computer and use it in GitHub Desktop.
env vars docker ENTRYPOINT
This file contains hidden or 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
#!/usr/bin/env bash | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
DOCKER_TAG="${DOCKER_TAG:-scratch0}" | |
cc="$(which ${CC:-x86_64-linux-musl-gcc})" # Choose any cross compiler, or just `gcc` if you're on a Linux box | |
cc_flags="${CC_FLAGS:--static}" | |
"$cc" "$DIR/env.c" -o "$DIR/env" -Wno-implicit-function-declaration "$cc_flags" | |
docker build --compress --force-rm --tag "$DOCKER_TAG" . | |
docker run --rm "$DOCKER_TAG" -e FOO=bar | |
# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
# HOSTNAME=eb77d24c5962 | |
# HOME=/ |
This file contains hidden or 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 scratch | |
COPY env /env | |
ENTRYPOINT ["/env"] |
This file contains hidden or 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
int main(int argc, char **argv, char** envp) { for(char** env=envp;*env!=0;env++) puts(*env, "\n"); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment