Networking across containers with nginx – need tips

I've been using Docker on my Synology DS918+ for a year and I happily run applications. These applications are have different networks such as:

  • their own network as they have frontend+db
  • run on the host network because don't work well with double-nat like Docker and Syncthing
  • run on a "generic" custom bridge network I created called main-net

I know: it's a mess.

I use one nginx container to expose some of these services over the internet and I want to simplify the configuration process.

When I create containers running in main-net, I manually assign a fixed IP address to containers so I can report that IP in the nginx config, but I've read that using fixed IP addresses in docker is a bad/unnecessary idea and I should use hostnames instead, and indeed sometimes I've faced IP conflicts.

Networks are isolated, so I can't lookup all hostnames from nginx. Is there a way to make nginx aware of all networks inside my docker environment? Or there's a better way to do so? I really want to improve my docker networks!

submitted by /u/olivercer
[link] [comments]
Source: Reddit