<p>I'm pretty new to Docker orchestration and managing a fleet of containers. I'm wanting to build an app that would give the user a container when they ran a command. What is the best tool and best way to accomplish this?</p>

<p>I plan on having a pool of CoreOS servers to run the containers on and I'm imagining the scheduler to have an API that I can just call to create the container.</p>

<p>Most of what I have seen with Nomad, Kubernetes, Docker Swarm, etc is how to provision multiple clusters of containers all doing the same thing. I'm wanting to be able to create a single container based on a users command and then be able to communicate with an API on that container. Anyone have experience with this?</p>

<p>I'd look at Kubernetes + the <a href="http://kubernetes.io/docs/user-guide/jobs/#what-is-a-job" rel="nofollow noreferrer">Jobs API</a> (short lived) or <a href="http://kubernetes.io/docs/user-guide/deployments/" rel="nofollow noreferrer">Deployments</a> (long lived)</p>

<p>I'm not sure exactly what you mean by command, but I'll assume its some sort of dev env triggered by a CLI, <code>make-dev</code>.</p>

<ol>
<li>User triggers <code>make-dev</code>, which sends a webhook to your app sitting in front of the Jobs API, ideally doing rate-limiting and/or auth.</li>
<li>Your app takes the command, sanity checks it, then fires off a Job/Deployment request + an <a href="http://kubernetes.io/docs/user-guide/ingress/" rel="nofollow noreferrer">Ingress rule</a> + <a href="http://kubernetes.io/docs/user-guide/services/" rel="nofollow noreferrer">Service</a></li>
<li>Kubernetes will schedule it out across your fleet of machines</li>
<li>Your app waits for the pod to start, then returns back the address of the API with a unique identifier (the same thing in the ingress rule) like <code>devclusters.com/foobar123</code></li>
<li>User now accesses their service at that address. Internally Kubernetes uses the ingress and service to route the requests to your pod</li>
</ol>

<p>This should scale well, and if your different environments use the same base container image, they should start really fast.</p>

<p>Plug: If you want an easy CoreOS + Kubernetes cluster plus a UI try <a href="https://coreos.com/tectonic" rel="nofollow noreferrer">https://coreos.com/tectonic</a></p>
