[英]docker for windows equivalent for “-v /var/run/docker.sock:/var/run/docker.sock”
I'm trying to control the host docker service from inside a container.我正在尝试从容器内部控制主机 docker 服务。
With Linux host and Linux container that is usually done like this: docker run -it -v /var/run/docker.sock:/var/run/docker.sock alpine
使用 Linux 主机和 Linux 容器,通常这样做:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock alpine
I now want to achieve the same with a Docker for Windows
host and a Linux container.我现在想使用
Docker for Windows
主机和 Linux 容器来实现相同的目标。
If tried quite a lot of things, mostly using DOCKER_HOST
with varying IP's like 10.75.0.1:2375
(IP of docker VM), 172.17.0.1:2375
(container IP) and 0.0.0.0:2375
as well as 192.168.178.xxx:2375
(host IP).如果尝试了相当多的东西,大都采用
DOCKER_HOST
具有不同IP的喜欢10.75.0.1:2375
(泊坞窗VM的IP), 172.17.0.1:2375
(集装箱IP)和0.0.0.0:2375
以及192.168.178.xxx:2375
(主机 IP)。
But apparently nothing responds on port 2375
or 2376
which I checked with something like: docker run -ti --rm alpine /bin/sh -c "apk add -U nmap && nmap -Pn 10.72.0.1 -p 2375-2376"
但显然在端口
2375
或2376
上没有任何响应,我检查了以下内容: docker run -ti --rm alpine /bin/sh -c "apk add -U nmap && nmap -Pn 10.72.0.1 -p 2375-2376"
At this point I'd like to know if this is even possible with Docker for Windows.在这一点上,我想知道 Docker for Windows 是否可以做到这一点。 Most information I found concerns
docker-machine / VirtualBox
combinations.我发现的大多数信息都与
docker-machine / VirtualBox
组合有关。
This works fine when running Linux containers using Docker for Windows too (but not when running Windows containers).这也适用于使用 Docker for Windows 运行 Linux 容器(但不适用于运行 Windows 容器)。 Just ensure that your shell won't rewrite paths or similar.
只需确保您的 shell 不会重写路径或类似内容。
I don't know how SO works so if necroposting is frowned upon then sorry.我不知道 SO 是如何工作的,所以如果 necroposting 不受欢迎,那么抱歉。 I also don't use docker on windows but this thread came up during my search for setting up portainer.
我也不在 Windows 上使用 docker,但是在我搜索设置 portainer 的过程中出现了这个线程。 I figured out the thing that I wanted to figure out and on first login portainer gave me this warning:
我想出了我想弄清楚的事情,并且在第一次登录时,portainer 给了我这个警告:
Ensure that you have started the Portainer container with the following Docker flag:
-v "/var/run/docker.sock:/var/run/docker.sock" (Linux).
or
-v \\.\pipe\docker_engine:\\.\pipe\docker_engine (Windows).
So, there you go.所以,你去了。 Hope that helps.
希望有帮助。
To complement the answer by @friism:补充@friism的答案:
Just ensure that your shell won't rewrite paths or similar.
只需确保您的 shell 不会重写路径或类似内容。
This was happening to me within Git Bash on Windows.这发生在我在 Windows 上的 Git Bash 中。 The solution, in this case, was to prefix all absolute paths with an extra slash (
/
) to disable the automatic path rewriting done by Git Bash.在这种情况下,解决方案是在所有绝对路径前面加上一个额外的斜杠 (
/
),以禁用 Git Bash 完成的自动路径重写。 ( Source ) (来源)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.