简体   繁体   English

Docker 上 Windows 无 Docker 桌面卷挂载

[英]Docker on Windows without Docker Desktop volume mounting

My goal is to use the docker-cli in Windows (docker.exe), but using Linux containers, without the installation of Docker Desktop.我的目标是在 Windows (docker.exe) 中使用 docker-cli,但使用 Linux 容器,而不安装 Docker Desktop。 I mainly followed these instructions to install Ubuntu 20.04-LTS using WSL2 and prepare everything that dockerd is running inside this instance.我主要按照这些说明使用 WSL2 安装 Ubuntu 20.04-LTS 并准备 dockerd 在该实例中运行的所有内容。 ( https://dev.to/_nicolas_louis_/how-to-run-docker-on-windows-without-docker-desktop-hik ) ( https://dev.to/_nicolas_louis_/how-to-run-docker-on-windows-without-docker-desktop-hik )

I currently start dockerd with "-H tcp://127.0.0.1" and it does work, I can pull images, run containers, build images etc. from a Windows terminal, my environment contains DOCKER_HOST=tcp://127.0.0.1:2375我目前使用“-H tcp://127.0.0.1”启动 dockerd,它确实有效,我可以从 Windows 终端拉取图像、运行容器、构建图像等,我的环境包含 DOCKER_HOST=tcp://127.0.0.1 :2375

What does not work is binding or mounting volumes to local directories, which used to work, when Docker Desktop was installed.当安装 Docker Desktop 时,不起作用的是将卷绑定或安装到本地目录,这在过去是有效的。

For example trying to run jboss/keycloak mounting /opt/jboss/keycloak/standalone/data to some local path gives me:例如尝试运行 jboss/keycloak mounting /opt/jboss/keycloak/standalone/data到一些本地路径给我:

docker: Error response from daemon: invalid mode: /opt/jboss/keycloak/standalone/data

which - again - used to work with Docker Desktop, so I do not assume an error in my call.这 - 再次 - 曾经与 Docker 桌面一起工作,所以我不认为我的电话有错误。

Can anyone help me getting this to work?谁能帮我让它工作?

Your docker daemon is running in WSL and you are just connecting to it with de docker command on Windows.您的 docker 守护程序正在 WSL 中运行,您只需在 Windows 上使用 de docker 命令连接到它。

This means that every docker command is actually executed on the WSL subsystem and paths should be specified accordingly.这意味着每个 docker 命令实际上都在 WSL 子系统上执行,并且应该相应地指定路径。

In particular you should specify paths in WSL, usually your C:/ drive is mounted in WSL under \mnt\c .特别是您应该在 WSL 中指定路径,通常您的C:/驱动器安装在 WSL 中的\mnt\c下。

I would suggest trying to modifying your run command with those paths, so something like:我建议尝试使用这些路径修改您的运行命令,例如:

docker run -v C:\test\folder:/opt/jboss/keycloak/standalone/data ...

Would become:会成为:

docker run -v /mnt/c/test/folder:/opt/jboss/keycloak/standalone/data ...

Make sure you pay attention to the slashes: in WSL you need a foreward slash ( / ) whereas windows does not really care.请务必注意斜杠:在 WSL 中,您需要一个正斜杠 ( / ),而 windows 并不关心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM