Created
May 16, 2017 15:33
-
-
Save fteychene/8e0464cb2ca6e867c1b0fa75ee961e52 to your computer and use it in GitHub Desktop.
Docker commands
This file contains 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
docker network create petclinic-db | |
docker run -d --net=petclinic-db --network-alias=mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test mysql:5.5 | |
docker build -t spring-petclinic:latest | |
docker run -p 8080:8080 --net=petclinic-db spring-petclinic:latest | |
for i in {1..5}; do; docker run --net=petclinic-db --network-alias=petclinic -d spring-petclinic:latest; done; | |
cat <<EOF >nginx.conf | |
server { | |
listen 80; | |
server_name petclinic.com localhost; | |
# Docker internal DNS | |
resolver 127.0.0.11 valid=1s; | |
location / { | |
# Use a variable and no upstream for proxy_pass to force Nginx to force re-resolve | |
# (workaround for a limitation of nginx) | |
# see https://www.ruby-forum.com/topic/4407628 | |
set $alias "petclinic:8080"; | |
proxy_pass http://$alias; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Forwarded-Proto https; | |
} | |
} | |
EOF | |
docker run -v $(pwd)/nginx.conf:/etc/nginx/conf.d/petclinic.conf --net=petclinic-db -p 80:80 -d nginx | |
echo "127.0.0.1 petclinic.com" >> /etc/hosts | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment