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

查看:772
本文介绍了是否有可能从容器到主机执行Docker调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

推荐答案

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

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

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.

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

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

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

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

这篇关于是否有可能从容器到主机执行Docker调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆