<p>You can run your application on a particular node of the cluster by defining it in the application level. For this, you need to add the "placement " parameter in the yaml file and specify the node's name to it, then it will deploy the container on that node. </p>

<p>Secondly, what type of scheduling have you implemented on Swarm CLuster? Let me clear your thought, there three of them: Spread, Bin-pack, and Random. By default, it is Spread, which identifies a number of containers on each node and deploys the new container on the node that has a small number of containers. Check the rest yourself.</p>

<p>Both of these points will solve your problem.</p>

CC BY-SA 4.0
2019-08-23T09:47:18.027Z
2019-08-23T09:47:18.027Z
saddique
<p>You can use the <a href="https://github.com/jenkinsci/docker-swarm-plugin" rel="nofollow noreferrer">docker-swarm-plugin</a>.</p>

CC BY-SA 4.0
2019-08-23T08:39:27.523Z
2019-08-23T08:39:27.523Z
Hedi Nasr
<p>I have a specific implementation of jenkins on docker. </p>

<p>My requirement is to start slave containers on demand and only when they are needed and then stop them after the pipeline has ran.</p>

<p>I have the jenkins master instantiated as a container, then using the docker socket I am able to run my pipeline in one or more other containers containers provisioned by jenkins, that I have specifically built for that purpose following the implementation described <a href="https://jenkins.io/doc/book/pipeline/docker/" rel="nofollow noreferrer">in the jenkins book</a>.</p>

<ul>
<li>master container - <a href="https://github.com/YiannisH/containerised-jenkins/blob/master/docker/master/Dockerfile" rel="nofollow noreferrer">https://github.com/YiannisH/containerised-jenkins/blob/master/docker/master/Dockerfile</a></li>
<li>slave container - <a href="https://github.com/YiannisH/containerised-jenkins/blob/master/docker/slave/Dockerfile" rel="nofollow noreferrer">https://github.com/YiannisH/containerised-jenkins/blob/master/docker/slave/Dockerfile</a></li>
</ul>

<p>The above mentioned implementation is implemented on one EC2 machine acting as a docker host.</p>

<p>However, that implementation has the flaw that is not highly available and I am only able to use the resources available on on server.</p>

<p>How can I implement this on a swarm cluster where I still have just one master jenkins container starting slave containers from the pipeline on a swarm cluster?</p>

<p>I cannot seem to find something similar after extensive searching, but I am sure it is in some way possible.</p>

<docker><jenkins><kubernetes>
Jenkins pipeline running using containers on an orchestration platform
yian
# Jenkins pipeline running using containers on an orchestration platform

(Asked by: username_0 on 2019-08-21)

I have a specific implementation of jenkins on docker.

My requirement is to start slave containers on demand and only when they are needed and then stop them after the pipeline has ran.

I have the jenkins master instantiated as a container, then using the docker socket I am able to run my pipeline in one or more other containers containers provisioned by jenkins, that I have specifically built for that purpose following the implementation described [in the jenkins book](https://jenkins.io/doc/book/pipeline/docker/).

* master container - <https://github.com/YiannisH/containerised-jenkins/blob/master/docker/master/Dockerfile>
* slave container - <https://github.com/YiannisH/containerised-jenkins/blob/master/docker/slave/Dockerfile>

The above mentioned implementation is implemented on one EC2 machine acting as a docker host.

However, that implementation has the flaw that is not highly available and I am only able to use the resources available on on server.

How can I implement this on a swarm cluster where I still have just one master jenkins container starting slave containers from the pipeline on a swarm cluster?

I cannot seem to find something similar after extensive searching, but I am sure it is in some way possible.

**Tags:** docker, jenkins, kubernetes


---

## 2 answers

### Answer by username_1 on 2019-08-23. Score: 1

You can run your application on a particular node of the cluster by defining it in the application level. For this, you need to add the "placement " parameter in the yaml file and specify the node's name to it, then it will deploy the container on that node.

Secondly, what type of scheduling have you implemented on Swarm CLuster? Let me clear your thought, there three of them: Spread, Bin-pack, and Random. By default, it is Spread, which identifies a number of containers on each node and deploys the new container on the node that has a small number of containers. Check the rest yourself.

Both of these points will solve your problem.


---

### Answer by username_2 on 2019-08-23. Score: 0

You can use the [docker-swarm-plugin](https://github.com/jenkinsci/docker-swarm-plugin).


---

