Skip to content

Instantly share code, notes, and snippets.

@stephenmelrose
Created October 6, 2016 10:12
Show Gist options
  • Save stephenmelrose/aa26424c38d8d15fc408957c4b14cd5f to your computer and use it in GitHub Desktop.
Save stephenmelrose/aa26424c38d8d15fc408957c4b14cd5f to your computer and use it in GitHub Desktop.
Docker nginx ENV Example
nginx:
image: <SNIP>
container_name: myapp-nginx
environment:
MY_HOSTNAME: "myhostname"
links:
- php
ports:
- "8000:80"
- "8001:81"
volumes:
- "./:/var/app"
- "./logs/nginx:/var/log/nginx"
# ...
# Set default run command
ADD start.sh /opt/start.sh
CMD ["/bin/bash", "/opt/start.sh"]
#!/bin/bash
# Replace hostname in config
sed -i "s#localhost#${MY_HOSTNAME}#" /etc/nginx/sites-available/default
# Start nginx
/usr/sbin/nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment