我正在尝试从容器内访问Docker远程API,因为我需要启动其他容器.
I'm trying to access Docker remote API from within a container because I need to start other containers.
主机地址为 172.19.0.1 ,因此我正在使用 172.19.0.1:2375/images/json 来获取图像列表(从主机上, localhost:2375/images/json 可以正常工作.
The host address is 172.19.0.1, so I'm using 172.19.0.1:2375/images/json to get the list of images (from host, localhost:2375/images/json works as expected.
我拒绝了该连接,因为Docker(对于Windows)侦听的是 127.0.0.1 而不是 0.0.0.0 .
The connection is refused, I guess because Docker (for Windows) listens on 127.0.0.1 and not on 0.0.0.0.
我试图更改配置(从UI和 daemon.json ),添加以下条目:
I've tried to change configuration (both from UI and daemon.json) adding the entry:
"hosts": ["tcp://0.0.0.0:2375"],但是守护程序无法启动.如何访问api?
but the daemon fails to start. How can I access the api?
推荐答案您可以在需要的容器内链接主机的/var/run/docker.sock.这样,您就不会通过开放的端口公开Docker Remote API.
You could link the host's /var/run/docker.sock within the container where you need it. This way, you don't expose the Docker Remote API via an open port.
请注意,它确实提供了对docker的类似root的访问.
Be aware that it does provide root-like access to docker.
-v /var/run/docker.sock:/var/run/docker.sock更多推荐
从容器访问Docker远程API
发布评论