docker-nginx
docker-nginx copied to clipboard
The behavior of .envsh executed by docker-entrypoint.sh
Describe the problem
The .envsh merged in #687 is a very nice solution, but the current implementation does not passed to nginx. This is due to bash/dash (POSIX spec?). This is because the pipeline is run in subshell. https://www.gnu.org/software/bash/manual/html_node/Pipelines.html
The pipeline does not affect the behavior of 20-envsubst-on-templates.sh because the environment variables are reflected in the pipeline, but it may be a confusing implementation. (In fact, I was fitted with a project that incorporated 20-envsubst-on-templates.sh.)
To Reproduce
cat << EOT >> Dockerfile
FROM nginx:latest
COPY 10-export-env.envsh /docker-entrypoint.d/
COPY nginx /usr/sbin/nginx
EOT
cat << EOT >> 10-export-env.envsh
#!/bin/sh
export FOO=bar
EOT
cat << EOT >> nginx
#!/bin/sh
env
EOT
chmod +x 10-export-env.envsh nginx
docker build -t test .
docker run --rm test
Expected behavior
Exported environment variables are reflected in nginx