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

Environment variables injection fails 20-envsubst-on-templates.sh: line 25: 3: Bad file descriptor

Open aosynsky opened this issue 2 years ago • 3 comments

According to official documentation https://hub.docker.com/_/nginx section "Using environment variables in nginx configuration (new in 1.19)".

But it's does not work due to bug inside docker container script: https://github.com/nginxinc/docker-nginx/blob/master/entrypoint/20-envsubst-on-templates.sh#L25

running this script always fails with error: /docker-entrypoint.d/20-envsubst-on-templates.sh: line 25: 3: Bad file descriptor

due to incorrect STDOUT used "&3", must be "&2"

aosynsky avatar Mar 28 '22 13:03 aosynsky

I think this script is not intended to be run directly but triggered from docker-entrypoint.sh

tomaszkrzyzanowski avatar Apr 26 '22 13:04 tomaszkrzyzanowski

Hi @oasynsky, can you tell a bit more on how you're trying to utilize the script? as @tomaszkrzyzanowski rightfully said, it's not intended to be ran manually. Thanks

thresheek avatar May 06 '22 08:05 thresheek

According to official documentation https://hub.docker.com/_/nginx section "Using environment variables in nginx configuration (new in 1.19)".

it not work /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up

Docker version 20.10.14, build a224086 nginx latest b692a91e4e15 8 days ago 142MB nginx version: nginx/1.23.1

version: '3.5'

services: web: image: nginx volumes: - ./templates:/etc/nginx/templates ports: - "8080:80" environment: - NGINX_HOST=foobar.com - NGINX_PORT=8080

server { listen ${NGINX_PORT}; listen [::]:${NGINX_PORT}; server_name ${NGINX_HOST}; charset utf-8; location / { root /storage; index index.html; autoindex on; autoindex_exact_size off; autoindex_localtime on; add_header Cache-Control no-store; } }

jackadam1981 avatar Aug 10 '22 07:08 jackadam1981

@jackadam1981 please open another issue, this does not seem relevant to this current issue.

Closing due to feedback timeout.

thresheek avatar Oct 11 '22 07:10 thresheek