
Ask HN: Is it possible to spawn docker instances from a Node.js app? - gladsva
Hey,<p>n.b - I have no prior experience in working with docker.<p>My question is, I want to create an internal company nodejs app that can spawn instances of a docker image dynamically. Ideally a user will navigate to the app, click the environment they want to create. The app will spin up the docker image and provide a link to the running image, which will be a website of some kind.<p>- Is this possible with docker?<p>- Is docker the right tool for this job?<p>- Are there any solutions that do this already?<p>Thanks.
======
nherment
Yes, like jonmurdoch mentioned, calling shell commands from your node
application will work.

However, the Docker CLI is really only a CLI and has no magic in it. If I
remember correctly, it even talks HTTP to the docker server (please don't take
that at face value).

In that case it should be possible to talk directly to docker through HTTP
calls.

...indeed, a quick search about "nodejs docker client" gives you a few
options, one of which is
[https://github.com/apocas/dockerode](https://github.com/apocas/dockerode).

~~~
gladsva
ahh.. awesome, this library looks to have everything I could need. Thank you.

------
jonmurdoch
I'm guessing the easiest way is to just shell out to the docker run command.

