Multiple different container all listening 127.0.0.1:80 on the same host machine

Hi, i request your help here because i’m in front of a big trouble :

I have 2 services defined in my docker-compose.yml which are typically two website (i’ll call them web1 and web2) web1 need web2 to work.

I WANT to be able to call web1 via web1.local (hostname pointing on 127.0.0.1) and to call web2 via web2.local (hostname pointing on 127.0.0.1).

I DON’T WANT to be obliged to call web1 via web1.local (hostname pointing on 127.0.0.1) and to call web2 via web1.local:8080 (hostname pointing on 127.0.0.1:8080).

I’m also getting crazy with different network configuration and frustrated by the fact that a simple apache server can make it work but not Docker …

I’ll be thanksfull you give me some help.

Thanks.

no can do… only ONE application can use a port at the same time.

you could use a something like apache or nginx to route a PATH 127.0.0.1/host1 and 172.0.0.1/host2
but you have to provide some different input to select the other app

docker does NOT provide ANY data routing… that is some other apps responsibility

Thanks … pretty boring that this is not possible …

It’s possible. Just have to use some additional software. You could NOT map the ports on to the host and access by ip address (which is what apache or nginx would do)

OK, well but what if ip has changed, which could be done randomly on docker …

You can set the IP on the docker run to control that. Docker create a network, and then use that and IP address parms

Hi, I got the same problem and solved it with traefik.
I did a reminder here https://github.com/jfm-dnd/docker4php-multiproject - in [fr] sorry - (stuff with docker4php from https://github.com/wodby/docker4drupal/issues/124). Maybe it’ll help ^-^