How to access multiple docker-compose instances with different domains on same machine

What is the best way to be able to run multiple docker compose instances on the same machine and be able to access multiple ports (e.g. 80 for web, 8983 for solr) on the same machine with different domain each?

You could easily forward the same ports from the containers to arbitrary high ports on the host’s localhost by using Docker Compose’s ports: key ( If you want custom DNS resolution to containers then you need to run your own DNS server and indicate that your host should point to it. If you are running Docker on Linux natively this might be do-able by resolving to the Docker bridge network IPs, but on Mac or Windows it involves additional pain of somehow connecting to the container in the VM directly. I’d just use high ports unless you want DNS entries very badly, in which case you need to put in the elbow grease to rig up dnsmasq etc.

1 Like

Thank you for your answer!

I think this is doable.

How about using some kind of proxy that would find the open ports and match the domains? Like jwilder nginx proxy for docker? Is there a similar solution for docker-compose?

You could do that (and in fact it would likely be required on something like OSX where you could direct requests to that proxy, and forward to the appropriate vhost/container) but the tricky part will always be exposing and using your custom DNS server from wherever you want app.docker (or whatever) to resolve to. You will need to set up software so that your host knows how to resolve requests that you make which are intended to land on containers.

I wish there were a ready-made solution to this…

There is dinghy available to at least take a look at. However I need to be clear that it is not an official Docker, Inc. solution, nor is it endorsed by Docker, Inc. I’m sure the Docker for Mac / Docker for Windows team are interested in potentially exploring functionality such as this some day. cc @avsm @dgageot @jeanlaurent

1 Like

Oh cool, dinghy DNS / http proxy is available as a completely separate piece as well: Nice one @codekitchen!

1 Like