Created
January 8, 2018 10:54
-
-
Save gangadhars/bf16b0a4f3c689a5f657363b4aae2e0f to your computer and use it in GitHub Desktop.
Run nginx container on custom port, using env variable "NGINX_PORT=<80>"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM nginx:latest | |
| LABEL maintainer="Biarca" | |
| COPY mysite.template / | |
| CMD ["/bin/bash", "-c", "export NGINX_PORT=${NGINX_PORT:-80}; envsubst < /mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server { | |
| listen \${NGINX_PORT}; | |
| 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; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this - another great start for what I need. I'm planning on mirroring all the nginx images based on the
seg3value in this item in thelfccncfrepository, using your trick withenvsubstslightly abstracted via a script that will be the entrypoint.As per https://hub.docker.com/_/nginx/ we can't just set
NGINX_PORTas the author has noted in the README for this item.