Docker Community Forums

Share and learn in the Docker community.

What happens with ports when Docker 1.12 schedules two containers on the same node?

Hi,

I have a little three-node swarm with one service:
# docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
3xuedrij5sxfd45ba2eeie2lf sstest1 Ready Active
cc37u6khsz24dsn715measzcm * mgr1 Ready Drain Leader
d5iblv32m69gwihax338beoef sstest2 Ready Active
# docker service ls
ID NAME REPLICAS IMAGE COMMAND
54e876l7ccdv QueryAggregator 2/2 build1:8084/query-aggregator

I’d like Docker to run that service on the two non-manager nodes, but it keeps putting both replicas on the same node:
# docker node ps 3xuedrij5sxfd45ba2eeie2lf
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
6t1465pc6wcg52vpd17h4p3j2 QueryAggregator.1 build1:8084/query-aggregator sstest1 Running Running 13 hours ago
5ksjl8vrzod88bvn3swfwvp8x _ QueryAggregator.1 build1:8084/query-aggregator sstest1 Shutdown Shutdown 14 hours ago
6cztvi9lggabmtjrfyt57x4u2 _ QueryAggregator.1 build1:8084/query-aggregator sstest1 Shutdown Failed 14 hours ago "starting container failed: er…"
0o7cuj38n0ijn8pp0j03t4o0g _ QueryAggregator.1 build1:8084/query-aggregator sstest1 Shutdown Failed 14 hours ago "starting container failed: er…"
cnryguqu43k8oliw0cqtgu203 QueryAggregator.2 build1:8084/query-aggregator sstest1 Running Running 13 hours ago
[root@srv-lon-consul1 ~]# docker node ps d5iblv32m69gwihax338beoef
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
3s1dutr8yod200hl03yucvptx QueryAggregator.1 build1:8084/query-aggregator sstest2 Shutdown Complete 13 hours ago
bzywjkp2vav32qlr1ynlfk9gn QueryAggregator.2 build1:8084/query-aggregator sstest2 Shutdown Complete 13 hours ago

I understand that Docker 1.13 will be better in this regard (#26259, as with others I don’t want one instance per node, I want two instances on two different nodes).
However, this means on one of my test boxes I have:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32e2ec0985b1 build1:8084/query-aggregator:latest “java -jar /query-agg” 13 hours ago Up 13 hours 8080/tcp QueryAggregator.2.cnryguqu43k8oliw0cqtgu203
7caf6d35365d build1:8084/query-aggregator:latest “java -jar /query-agg” 13 hours ago Up 13 hours 8080/tcp QueryAggregator.1.6t1465pc6wcg52vpd17h4p3j2

Docker is exposing this service on port 32000, so, given that I have two replicas on the same node, both theoretically responding to port 32000, what will actually happen to inbound requests on port 32000?
How are they distributed between the containers?

Thanks