Hi @julianopache. I’m trying to make sure I understand your question correctly before giving an answer…
Is what you’re asking is whether you can start another container (B) from within container A? Or are you wanting to run a command in container B with a process running in Container A?
I don’t believe this is possible if it’s the second question, as the point of containers is to isolate the process space from other containers. Each can only run processes in their own container. Having said that, if the process in Container B listens on the network for commands for it to run, assuming that the binary for the process is included in the build of the image for Container B, you might be able to send such a message to Container B from Container A that will cause Container B to run the requested process.
If you’re rather wanting to start another Container (B) from with Container A, this is essentially Docker in Docker. The way to arrange that is to have the Docker daemon on the host listen on a TCP port instead or in addition to the normal file-based socket. Container A then must also include the
docker command in its image. Also, in order for Container A to know what ip address and port to which it should connect, those should be passed to Container A as environment variables on startup. To be clear, these are the Docker Host’s ip address and TCP port on which it is listening for Docker API calls. Container A will make calls like
docker -H <ip address>:<port> ... and the docker daemon on the host machine will create the container as requested, assuming everything is setup correctly. A point of concern though is that if someone were to compromise Container A and gain access to it, they could run arbitrary containers from your container. For that reason, it would be best if Container A had no external network access which might be compromised.
Not sure if I answered your question or not. If not, please post an update with more details about exactly what you’re trying to accomplish.