Docker Community Forums

Share and learn in the Docker community.

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

docker

(Kevintherage) #1

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.


(Sam) #2

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


(Kevintherage) #3

Thanks … pretty boring that this is not possible …


(Sam) #4

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)


(Kevintherage) #5

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


(Sam) #6

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