Errorum
Errorum

Reputation: 223

Inspect Docker Containers on Host from Container on same Host

I'm in the process of containerizing a service which monitors other services, many of which are also running on containers. Right now, it runs docker inspect from a Python subprocess on the host to monitor other services' containers. How can I get similar information from within another container?

I've considered running the same commands on the host via ssh, but it seems like there should be a better way. I can't be the first person to want to have one container monitor others, but all I find on the web is 3rd party solutions, which seem overkill for the problem at hand.

Upvotes: 0

Views: 173

Answers (1)

Conor Mongey
Conor Mongey

Reputation: 1227

You can mount the docker socket inside the container that contains your python program.

docker run -v /var/run/docker.sock:/var/run/docker.sock my-python-program

Upvotes: 1

Related Questions