3 ms·
Ask HN: Is it possible to spawn docker instances from a Node.js app?
Hey,
n.b - I have no prior experience in working with docker.
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.
- Is this possible with docker?
- Is docker the right tool for this job?
- Are there any solutions that do this already?
Thanks.
- jonmurdoch 10y agoI'm guessing the easiest way is to just shell out to the docker run command.
- nherment 10y agoYes, 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 10y agoahh.. awesome, this library looks to have everything I could need. Thank you.