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

template can't use default variables

Open wcollin opened this issue 1 year ago • 1 comments

docker-compose.yaml: version: '3'

services: web: image: nginx volumes: - ./templates:/etc/nginx/templates ports: - "8080:8080"

templates/default.conf.template: server { listen ${NGINX_PORT:-8080}; server_name localhost;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

}

error: /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: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh 20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up 2024/10/16 06:35:14 [emerg] 1#1: invalid port in "${NGINX_PORT:-8080}" of the "listen" directive in /etc/nginx/conf.d/default.conf:2 nginx: [emerg] invalid port in "${NGINX_PORT:-8080}" of the "listen" directive in /etc/nginx/conf.d/default.conf:2

wcollin avatar Oct 16 '24 06:10 wcollin

Templates are using envsubst tool so it is expected behavior.

oxpa avatar Oct 16 '24 11:10 oxpa

thanks,i set default variables in Dockerfile ENV NGINX_PORT

wcollin avatar Oct 25 '24 03:10 wcollin

Thanks for the update!

oxpa avatar Oct 25 '24 11:10 oxpa