Docker Community Forums

Share and learn in the Docker community.

Connecting containers to manage each other


(Dorrfg) #1

Hello,
Consider this scenario, in which I have two containers:

  • Redis container: A container that runs an image straight from Docker Hub. It doesn’t have to be Redis, the point is that I didn’t change anything about it. It can also be ElasticSearch, for example.
  • “Redis Manager” container: A container that runs my code, responsible for reacting to events in the system by changing the Redis configuration and restarting it.

Questions:

  1. Is this a good practice in terms of how to manage containers configuration? I don’t want the host to manage configurations.
  2. Can a container see another container’s processes and send them signals? For instance, killing a process or running a command on the other container.

Thanks.


(Jeff Anderson) #2

To manage containers, generally you’ll need to be able to communicate with the docker daemon. One way to do this is to share in the /var/run/docker.sock socket:

docker run -v /var/run/docker.sock:/var/run/docker.sock ...

Once you can communicate with the docker daemon, you can pretty much do anything you can do with docker, including dealing with other containers.


(Dorrfg) #3

Thanks for the reply,
Is there any way for a container to see process from another container? Or can it only manage it as a black box?

Thanks,
Dor.


(Jeff Anderson) #4

It’s just the same as managing containers from any other docker client.

You can see processes running with the docker top command. You can spawn new processes inside an existing container with docker exec. And so forth.