Answer the question
In order to leave comments, you need to log in
Why doesn't Docker map ports other than 80?
Hello ,
for Docker version 1.9.0, build 76d6bc9
on Ubuntu 14.04.3 LTS
, there is this docker-compose.yml:
dc1:
image: php
ports:
- "8081:8081"
expose:
- "8081"
dc2:
image: php
ports:
- "8082:8082"
expose:
- "8082"
80/tcp, 0.0.0.0:8081->8081/tcp dс_1
80/tcp, 0.0.0.0:8082->8082/tcp dс_2
docker inspect -f "{{.NetworkSettings.IPAddress}}" dc_1 -> 172.17.0.4
curl 172.17.0.4:8081 -> curl: (7) Failed to connect to 172.17.0.4 port 8081: Connection refused
docker inspect -f "{{.NetworkSettings.IPAddress}}" dc_2 -> 172.17.0.5
curl 172.17.0.5:8082 -> curl: (7) Failed to connect to 172.17.0.5 port 8082: Connection refused
curl 172.17.0.4:80 -> OK
dc1:
image: php
ports:
- "8081:80"
Answer the question
In order to leave comments, you need to log in
Perhaps this is the case:
ports:
- "8082:8082"
expose:
- "8082"
You open the same ports both outside the docker networks and inside the docker network for containers, and therefore it turns out that docker cannot simultaneously provide a port for both the outside world and internal networks.
You can also try to run the container something like: docker run -tid -p 8081:8081 dc1
So at least it should work. Why it does not work through compose, alas, I will not say. It may only work when the servers are running together
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question