是否有可能从容器到主机执行Docker调用?(Is it possible to perform Docker-call from a container into the host?)

627 IT屋

I would like to be able to, e.g., restart host containers from inside a container.

Does anyone know whether there is any way I could do that?

解决方案

Assuming that your question is "Is it possible to perform Docker-call from a container into the host?"

Yeah, sure it is possible! The communication with the Docker daemon goes through a socket. By default this socket is the unix:///var/run/docker.sock. Your manager-container just need access (and permission) to this socket.

Note that an option of the Docker daemon (I'm looking at ou -H, --host) allows the communication through TCP (or even a fd).

You then just need a Docker client (any Docker API implementation) to communicate.

我想能够,例如,从容器内重新启动主机容器。



有谁知道是否有任何方法可以做到这一点? / p>

解决方案

假设你的问题是"是否有可能从容器到主机执行Docker调用?"< / em>



是的,一定可以!
与Docker守护程序的通信通过一个套接字。默认情况下,该套接字是 unix:///var/run/docker.sock 。您的管理器容器只需要访问(和许可)到此套接字。



请注意,Docker守护程序的选项(我正在查看ou -H,--host )允许通过 TCP (或甚至 fd )。



然后您只需要一个Docker客户端(任何Docker API实现)进行通信。


本文地址:IT屋 » 是否有可能从容器到主机执行Docker调用?