Search code examples
jenkinsdockerjenkins-pluginsjenkins-docker

how to configure docker to limit the range of ports for spinning up containers


We are using Jenkins and docker for doing CI/CD. Our Jenkins is setup as master/slave style, where slaves are distributed across different data centers. when a new build needs to happen Jenkins master identifies a slave in one of the DC and spin up a ephemeral container and tear it down once done.

Due to firewall limitations, we only have about 10 ports open for the slaves in some of the DCs. for example Port Range: 8000 - 8010. In general docker uses the linux port ranges 32768 to 61000. The problem is Jenkins master can not talk to the containers if the host port is bound out of 8000 - 8010. Jenkins docker plugin has limitation where you can not bind multiple ports (may be I am wrong here). I would like to know if any way we can configure this at docker end or in Jenkins docker plugin.


Solution

  • After researching in many forums and talking to people, this is not possible or recommended even to try doing. The recommended implementation to overcome this issue is to move to Docker Swarm,

    1. where you have only one virtual docker cloud
    2. which takes care of spinning up containers behind the scenes and keep it ready for consumption even before the need arises. The configurations options are flexible.

    Read more about Swarm here https://docs.docker.com/swarm/