访问容器内的Docker插座 [英] Access Docker socket within container
问题描述
我正在尝试创建一个容器,可以通过docker套接字文件(主机 - / var / run/docker.sock)访问Host Docker远程API。
I am attempting to create a container that can access the host docker remote API via the docker socket file (host machine - /var/run/docker.sock).
答案此处建议将请求代理到套接字。我怎么会这样做?
The answer here suggests proxying requests to the socket. How would I go about doing this?
推荐答案
我想出来了。您可以通过卷参数
I figured it out. You can simply pass the the socket file through the volume argument
docker run -v /var/run/docker.sock:/container/path/docker.sock
正如@zarathustra指出的那样,这可能不是最好的想法。请参阅: https:/ /www.lvh.io/posts/dont-expose-the-docker-socket-not-even-to-a-container.html
As @zarathustra points out, this may not be the greatest idea however. See: https://www.lvh.io/posts/dont-expose-the-docker-socket-not-even-to-a-container.html
这篇关于访问容器内的Docker插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!