docker-nginx icon indicating copy to clipboard operation
docker-nginx copied to clipboard

The behavior of .envsh executed by docker-entrypoint.sh

Open yu-shiba opened this issue 1 year ago • 6 comments

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

yu-shiba avatar Jan 21 '23 01:01 yu-shiba