简体   繁体   English

Pycharm Docker 带有无效音量规范的远程单元测试调试

[英]Pycharm Docker remote unittest debugging with invalid volume specification

I have the following problem.我有以下问题。 I have a project which I want to debug via PyCharm and a docker image via ssh remote connection to some server.我有一个项目,我想通过 PyCharm 和 docker 图像通过 ssh 远程连接到某个服务器进行调试。 For standard debugging it is no problem.对于标准调试,这是没有问题的。 It works!有用!

Docker Desktop is installed on windows. PyCharm 2021.3.3 is set up. Docker桌面安装在windows上。PyCharm 2021.3.3设置。 Windows Linux path conversion is setup in the enviromental variables. Windows Linux 环境变量中设置了路径转换。 But when I start a debugging process of a unit test with the same docker image, I get the following error:但是,当我使用相同的 docker 图像开始单元测试的调试过程时,出现以下错误:

Cannot run the remote Python interpreter: invalid volume specification: 'C:\project:/opt/project:rw'**无法运行远程 Python 解释器:无效的卷规范:'C:\project:/opt/project:rw'**

在此处输入图像描述

在此处输入图像描述

This also worked for me before the system got a fresh windows installation.在系统重新安装 windows 之前,这对我也有用。 So my guess is that the unittest docker process somehow uses another part of the docker engine where I do not have the permission to process the windows Linux path conversion?所以我的猜测是 unittest docker 进程以某种方式使用了 docker 引擎的另一部分,我没有权限处理 windows Linux 路径转换? the "rw" of the exception is read, write, isn't it?异常的“rw”是读,写,不是吗? Furthermore it seems like it totally ignores the configuration file because i set a path to k where i map my project to but it has the project dir of C: in the exception message此外,它似乎完全忽略了配置文件,因为我设置了一个指向 k 的路径,其中我的项目指向 map,但它的项目目录为 C:在异常消息中

I also tried different dokcer desktop version and different pycharm versions.我还尝试了不同的 dokcer 桌面版本和不同的 pycharm 版本。

Based on the error message you provided, it looks like there is an issue with the volume specification in the Docker configuration for your PyCharm debugging setup.根据您提供的错误消息,您的 PyCharm 调试设置的 Docker 配置中的卷规范似乎存在问题。 In the error message, the volume specification is shown as C:\project:/opt/project:rw, which is not a valid format for defining a volume in Docker.在错误消息中,卷规范显示为 C:\project:/opt/project:rw,这不是用于在 Docker 中定义卷的有效格式。

To correct this issue, you will need to update the volume specification to use the correct format for defining volumes in Docker. The correct format for defining a volume in Docker is host-dir:container-dir, where host-dir is the path to the directory on the host machine that you want to mount as a volume, and container-dir is the path where the volume will be mounted within the Docker container.要更正此问题,您需要更新卷规范以使用正确的格式在 Docker 中定义卷。在 Docker 中定义卷的正确格式是 host-dir:container-dir,其中 host-dir 是到主机上要挂载为卷的目录,container-dir 是卷将挂载到 Docker 容器中的路径。

For example, if you want to mount the C:\project directory from the host machine as a volume at the /opt/project directory within the Docker container, you would specify the volume as C:\project:/opt/project.例如,如果要将主机中的 C:\project 目录挂载为 Docker 容器内的 /opt/project 目录中的卷,则应将该卷指定为 C:\project:/opt/project。 Additionally, you can specify additional options for the volume, such as:rw to make the volume writable, by appending them to the end of the volume specification after a comma.此外,您可以为卷指定其他选项,例如:rw 以使卷可写,方法是将它们附加到卷规范末尾的逗号后。

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

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