<p>Is there any way using k8s or swarm or any other option to automate the spawn of containers according to requests.</p>

<p>Part of my project is to send an event to an eventbus (rabbitMQ) which has a listener to the events once an event arrives then start a new container for each message.</p>

<p>The only option I found was to mount the host engine to the event listener container that and I don't really like this solution.</p>

<p>I would like an orchestrator to "listen" to the eventbus or to any other request queue container spawn requests and start them.</p>

<p>Thank you</p>

IB.
<p>This is a broad question, there are many ways on you can accomplish this.</p>

<p>For example:</p>

<ol>
<li><p>Write a simple bash script on an infinite loop that gets a message from RabbitMQ using another program (perhaps written <a href="https://www.rabbitmq.com/tutorials/tutorial-one-python.html" rel="nofollow noreferrer">python</a> with Pika). As soon as it gets a message, issue a <code>docker run ...</code></p></li>
<li><p>Write your own program with <a href="https://pika.readthedocs.io/en/stable/" rel="nofollow noreferrer">Pika</a> that waits for a message and then creates a pod in Kubernetes using the <a href="https://github.com/kubernetes-client/python" rel="nofollow noreferrer">python K8s client</a>.</p></li>
<li><p>You can also use any other language that has a client API for RabbitMQ, Docker, and/or Kubernetes.</p></li>
</ol>
