The behavior of .envsh executed by docker-entrypoint.sh
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 3.5k
- Forks
- 1.8k
- Avg merge
- 42m
- Merged PRs (30d)
- 2
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect docker-entrypoint.sh and the scripts in /docker-entrypoint.d/, especially 20-envsubst-on-templates.sh; start by running the Dockerfile reproduction in the issue and tracing how 10-export-env.envsh is executed. Done means exported variables from .envsh are visible to the nginx entrypoint while existing envsubst behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, shell
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100