Call a container from another one

Supposing we have two container: one is based on a nodejs container who use npm-watch to perform an action when some watched file are changed. Now the action it’s to perform is to call another container, a phpunit container to check some tests.

npm performs this only by docker command, but to do that it should call it in host environment, not in local, in this case an error is launched about the fact that docker isn’t installed.

Now I see only three scenarios:

  1. Installing node, npm and npm-watch in the same container where there is phpunit; (this isn’t a scalable solution).

  2. Installing in node a client that can call another container with phpunit where I put a server. When some file change, npm performs by command line a request (alike a curl one) to the other container where a server perform phpunit and sends back a response or redirects it to a stout. Both container have to be on the same network to do that.

  3. Using a third container alike Jenkins that can host two volume one for docker.sock another for docker client to get back an npm-watch curl request and perform phpunit in host env. Maybe It can be done the same using the node container with docker.sock and docker executable or use ssh client to send a ssh command to host env that use a server and perform in this way the docker … phpuni/phpunit command.

Do I miss something?