Run new docker container (service) from another container on some command

12/3/2019

Does exist any way to do this:

  • run one service (container) with main application - server (flask application);
  • server allows to run another services, them are also flask applications;
  • but I want to run each new service in separate container ?

For example, I have endpoint /services/{id}/run at the server, each id is some service id. Docker image is the same for all services, each service is running on separate port.

I would like something like this:

request to server - <host>//services/<id>/run -> application at server make some magic command/send message to somewhere -> service with id starts in new container.


I know that at least locally I can use docker-in-docker or simply mount docker socket in container and work with docker inside this container. But I would like to find way to work across multiple machines (each service can run on another machine).

For Kubernetes: I know how create and run pods and deployments, but I can't find how to run new container on command from another container. Can I somehow communicate with k8s from container to run new container?


Generally:

  • can I run new container from another without docker-in-docker and mounting docker socket;

  • can I do it with/without Kubernetes?.


Thanks for advance.

-- Alex Kolosov
docker
kubernetes

1 Answer

12/20/2019

I've compiled all of the links that were in the comments under the question. I would advise taking a look into them:

Docker:

Kubernetes:

-- Dawid Kruk
Source: StackOverflow