Search code examples
dockerdocker-swarm

Docker Swarm - Map ports and Scaling


I am currently using Docker Engine 1.11, and I am investigating if its possible for me to move to Docker 1.12 and use Swarm. I am currently using Docker to run 50+ Bamboo agents, all of which need to have a port mapped to a port on the server. For instance, each docker container needs to have port 4000 available, so when I do Docker run, I do-

Docker run -p 10000:4000 myimg
Docker run -p 10001:4000 myimg
Docker run -p 10002:4000 myimg
Docker run -p 10003:4000 myimg

In Docker Swarm, from what I understand, I would run the following command to scale my service to 50 containers

docker service scale helloworld=5

But, if I did this, then they would all be trying to map to the same port. How can I accomplish this? Is it possible?


Solution

  • No, you can't.

    It's just one key function that docker service provides that a single port can map to multi containers(service discovery)

    And another one is when container fails, swarm will start a new one.(self healing)

    I know nothing about Bamboo, so I can't tell you if there's a way to run bamboo service with the swarm mode.