简体   繁体   English

docker for windows 等效于“-v /var/run/docker.sock:/var/run/docker.sock”

[英]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"但显然在端口23752376上没有任何响应,我检查了以下内容: 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.

相关问题 FATA [0000]获取http:///var/run/docker.sock/v1.17/version:拨打unix /var/run/docker.sock - FATA[0000] Get http:///var/run/docker.sock/v1.17/version: dial unix /var/run/docker.sock 通过将 /var/run/docker.sock 作为卷安装到 docker 容器,我可以做些什么? - What are the things I can do by mounting /var/run/docker.sock as a volume to a docker container? "docker.sock 权限被拒绝" - docker.sock permission denied 从容器内部访问docker.sock - Access docker.sock from inside a container 无法连接到位于 unix:/var/run/docker.sock 的 Docker 守护程序。 docker 守护程序是否正在运行? - Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running? 从安装了`docker.sock`的docker容器内查找主机上的开放端口 - Find open ports on host from inside a docker container with `docker.sock` mounted 存在docker.sock且在docker容器中运行权限时无法连接到docker.sock - Unable to connect to docker.sock when it exist with permissions running inside docker container Docker无法通过套接字'/var/run/mysqld/mysqld.sock'连接到本地MySQL服务器(2)Ubuntu - Docker Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Ubuntu docker-engine运行级别:/ var / run / utmp:没有这样的文件或目录 - docker-engine runlevel:/var/run/utmp: No such file or directory 错误:'无法通过套接字 '/var/run/mysqld/mysqld.sock' (2)' 连接到本地 MySQL 服务器 - 缺少 /var/run/mysqld/mysqld.sock - error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' -- Missing /var/run/mysqld/mysqld.sock
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM