- https://github.com/nginx-proxy/nginx-proxy
- https://github.com/nginxproxy/nginx-proxy
- https://github.com/nginx-proxy/nginx-proxy/wiki/Docker-Compose-Example
- https://github.com/speto/docker-db-tunnel
- https://github.com/codekitchen/dinghy-http-proxy
- https://github.com/wellic/bash_tools/blob/master/bin/sites/vhost_add.sh
- https://github.com/wellic/bash_tools/blob/master/bin/sites/docker-compose.override.yml
- https://github.com/jwilder/whoami
Other solutions:
- case 1: hard coded IP
services:
db:
image: mysql:latest
container_name: db
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: true
networks:
default:
ipv4_address: 10.10.10.250
web:
image: node:latest
container_name: web
depends_on:
- nginx-proxy
extra_hosts:
- "db:10.10.10.250"
networks:
default:
ipam:
config:
- subnet: 10.10.10.0/24
gateway: 10.10.10.1
add to /etc/hosts
10.10.10.250 db.docker
- case 2: nginx-proxy :
services:
nginx-proxy:
image: nginxproxy/nginx-proxy
ports:
- "80:80"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
db:
image: mysql:latest
container_name: db
depends_on:
- nginx-proxy
environment:
VIRTUAL_HOST: db.docker
VIRTUAL_PORT: 3306
web:
image: node:latest
container_name: web
depends_on:
- nginx-proxy
environment:
VIRTUAL_HOST: web.docker
VIRTUAL_PORT: 3000
add to /etc/hosts
$ IP=$(docker inspect db -f json | jq -r '.[].NetworkSettings.Networks[].IPAddress' | sort | head -1)
$ echo "$IP db.docker" >> /etc/hosts
$ echo "127.0.0.1 web.docker" >> /etc/hosts
- case 3: combined
add to
/etc/hosts
add to
/etc/hosts