Needing help: Making containers available via proxy?

Hello guys and girls,
I’ve the feeling of better introducing myself first. I’m a 20 y/o junior web developer from Germany. I just finished school and started working as a PHP Developer at a local Software Development Company.
A few weeks ago I started learning about Docker and I decided to build my very own development environment with Docker on a local server. (Yes, a server… not my local Desktop having Docker installed and exposing the Ports to the other PCs in the local network)
After a few days of trying I now do need some help. I have some local containers with the services I would like to have in my network and till now I simply exposed them over a few ports. Now I’d like to improve this. I’d like to be able to connect to my server using names like [name of the container].[name of the host server] instead of [name of the host server]:[port]! I tried to to this using nginx as a proxy but I just couldn’t get a connection. I just got time-outs!
Now my question is: Does anybody have a solution for being able to call the servers like this? Did I forget something like a setting? Do I need to install a local DNS on my server and let my router forward all DNS requests to that DNS? Does anybody have anything like a blog posting concearning my problem?

If you need any more information I’m free to answer your questions.
Greetings
sironheart

The clean way would be to setup a local DNS server and register the service names (hint: wildcard domains might help to reduce the management overhead) as subdomains in your domain and resolve them to your docker host or cluster. If you just want the host resolution to work on your local computer, you could cheat by modifying your computers /etc/hosts file (I don’t recall the path to the file on Windows systems, I know it exists though). I would recommend the clean way :slight_smile:

Once this is handled, you can use any reverse proxy and create reverse proxy rules per subdomain. If you feel comfortable with nginx, you can manualy create the rules. If you prefer a more advanced solution, you might want to check traefik, which allows to configure the reverse proxy rules using container labels (or service labels in case of swarm sevices).

1 Like