I made a fastAPI docker container, and it's running fine, unless 1 command...
I need it to restart another docker container when some event happen.
I have a server[host], running docker, docker is running containerA (fastAPI) and containerB ...
How can I make containerA run a command that will make the host execute this command:
docker restart containerB
Note, the host OS is linux.
I tried to use python's subprocess.run() , but it didn't work of course , containerA doesn't have docker installed, so of course it has no docker commands.
I've read articles saying that mounting unix socket will work, I tried mounting '/var/run/docker.sock:/var/run/docker.sock' but it didn't work as well.
If you have an idea how to make it work, I'd be grateful.
Thanks.
/var/run/docker.sock
is indeed the usual approach for this; what didn’t work in your case?