Skip to content

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

Open
@yu-shiba

Description

@yu-shiba

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions