-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Can't get .conf.template files to work with env variables/file
I'm having an issue getting .conf.template files to generate a .conf file within the /etc/nginx/conf.d
directory.
I have the following docker-compose.yml file:
# docker-compose.yml
version: '3.8'
services:
nginx-proxy:
image: nginxproxy/nginx-proxy:1.5
container_name: nginx-proxy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
environment:
- TRUST_DOWNSTREAM_PROXY=false
- KEEPALIVE_REQUESTS=${KEEPALIVE_REQUESTS}
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./certs:/etc/nginx/certs
- ./config/custom.conf.template:/etc/nginx/templates/custom.conf.template
networks:
- nginx-proxy-network
networks:
nginx-proxy-network:
name: nginx-proxy-network
Within the mounted config folder I have the following custom.conf.template
file and .env file
# custom.conf.template
keepalive_requests ${KEEPALIVE_REQUESTS};
# .env
KEEPALIVE_REQUESTS=9999
When I start the proxy container using docker compose up
and navigate to the /etc/nginx/templates
folder to see if everything got mounted correctly I get the following output:
➜ docker git:(develop) ✗ docker exec -it nginx-proxy bash
root@d9d62440ba84:/app# cd /etc/nginx/templates
root@d9d62440ba84:/etc/nginx/templates# ls
custom.conf.template
root@d9d62440ba84:/etc/nginx/templates# cat custom.conf.template
keepalive_requests ${KEEPALIVE_REQUESTS};
The issue
However when after that I navigate to the /etc/nginx/conf.d
folder, I just see the default.conf
file. I expected to see custom.conf
aswell.
root@d9d62440ba84:/etc/nginx/templates# cd /etc/nginx/conf.d
root@d9d62440ba84:/etc/nginx/conf.d# ls
default.conf
Using the base nginx container does work
I also tried this exact same setup using a base nginx:1.25.4
image, and everything worked just fine.
It seems as if the parent nginx image entrypoints (mainly https://github.com/nginxinc/docker-nginx/blob/master/stable/debian/20-envsubst-on-templates.sh) arent triggered correctly/overridden by something the proxy does?
Thanks! 🙏🏻