Skip to content

A docker container to demonstrate using environment variables - displays the variables in a semi-dynamic nginx configuration. The ENVs are derived from the container at startup and consumed by nginx.

Notifications You must be signed in to change notification settings

YaleUniversity/nginxcontainerenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Simple nginx container to verify functionality of container secrets in spinup, or in docker

docker build .

example running container docker run -it --env API_HOST=localhost --env API_PORT=1234 --env testsecret=blah --name nginxcontainerimage f4a8469b5de7

dockerhub push

The dockerhub userID and repository name:

  • mydockerhubuser/createsecrets

docker login --username=mydockerhubuser

docker build . && docker rm friendlyimagename

docker tag 1c4394e94846 mydockerhubuser/createsecrets:nginxenv

docker push mydockerhubuser/createscripts:nginxenv

example running container

docker run -it --env API_HOST=localhost --env API_PORT=1234 --env testsecret=blah --name friendlyimagename f4a8469b5d e7

get the container ID so you can connect to it and verify the image has the files modified with the ENVs docker ps

exec into the container docker exec -it c9d631a99c95 bash|ash

check out files cat /etc/nginx/conf.d/default.conf resolver 127.0.0.11 valid=10s; # recover from the backend's IP changing

server { listen 80;

location / { root /usr/share/nginx/html; }

location /api { proxy_pass http://localhost:1234; proxy_set_header Host $http_host; } }

server { listen 80;

location / { root /usr/share/nginx/html; }

location /api { proxy_pass http://localhost:1234; proxy_set_header Host $http_host; } }

cat /usr/share/nginx/html/index.html

<title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style>

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

testsecret: blah

API_HOST: localhost

API_PORT: 1234

About

A docker container to demonstrate using environment variables - displays the variables in a semi-dynamic nginx configuration. The ENVs are derived from the container at startup and consumed by nginx.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published