Simplest way to do this is Docker Compose. You can simply define which services you want and Docker Compose automatically link them in a dedicated network. Suppose you have your goapp
, redis
, and mysql
instance and want to use nginx
as your reverse proxy. Your docker-compose.yml
file looks as follows:
services:
redis:
image: redis
mysql:
image: mysql
goapp:
image: myrepo/goapp
nginx:
image: nginx
volumes:
- /PATH/TO/MY/CONF/api.conf:/etc/nginx/conf.d/api.conf
ports:
- "443:443"
- "80:80"
The advantage is that you can reference any service from other services by its name. So from your goapp
you can reach your MySQL server under hostname mysql
and so on. The only exposed ports (i.e. reachable from the host machine) are 443
and 80
of nginx
container.
You can start the whole system with docker-compose up
!