访问容器内的Docker插座 [英] Access Docker socket within container

查看:170
本文介绍了访问容器内的Docker插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个容器,可以通过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屋!

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