0

I have a node.js Websocket server listening on port 443 running in a Docker Container(let's say ws_container) that is connected to both the host network and an internal network , let's say internal_net.

When the Websocket server running in ws_container establish a connection with a Websocket, I want to spawn a new container(let's say an Ubuntu 18.04 container) connected to internal_net from the ws_container.

I came across this question Is it possible to start a stopped container from another container , that states the best way to accomplish this is to mount the docker socket in the container(in my case ws_container).

Are there any better ways of solving the problem?

1 Answers1

0

It depends where you want to spawn container. Containers run where docker daemon runs. To connect to the daemon you can use socket if the daemon is on same machine or you can use tcp connection to spawn container on any daemon that you have access to.

If you use some kind of orchestration like swarm or kubernetes then you can use some management tools to do that, like portainer, open shift or others.

However in most of the cases mapping socket is the easiest and sufficient option to do.

Miq
  • 3,931
  • 2
  • 18
  • 32