我希望使用远程容器功能来测试新的远程开发扩展。我抓取了样例Python项目并使用Remote-Containers: Open Folder in Container...函数打开了它。

初始化过程开始的很好,通过一些码头建设没有问题。Dockerfile中的步骤1-3成功,然后步骤4(Dockerfile的13/14行)抛出一个异常并退出,因为RUN命令包含一个AND_IF操作符(&&)。这是因为它被作为子命令传递给不支持PowerShell的&&。
我遵循使用说明来准备使用远程容器功能的系统,包括将我的驱动器(C:和D:)添加到共享驱动器中。
到目前为止,我尝试过解决以下问题:
terminal.integrated.shell.windows)的默认外壳Remote-Containers: Open Folder in Container...,选择python:3作为目标Docker映像上述任何步骤都没有产生任何不同的结果。
Docker检查显示,Config->Shell设置为:
"Shell":
[
"powershell",
"-Command",
"$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"
]而Config->Cmd设置为:
"Cmd":
[
"powershell",
"-Command",
"$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';",
"apt-get update && apt-get -y install --no-install-recommends apt-utils 2>&1"
]完整的容器配置是这里。
异常的原因是显而易见的,但我无法理解为什么像上面那样将Dockerfile RUN指令传递给PowerShell。
我正在Windows 10 (1809年)上运行Visual代码-内部人员(1.36.0-内幕)和Docker Engine 18.09.2。
当步骤4失败时,异常会产生以下错误(我已经包括了前面成功的上下文步骤;为了简洁起见,在步骤2中将pip安装扁平化):
Setting up container for folder: d:\Development\vscode-remote-try-python-master
Run: docker build -f d:\Development\vscode-remote-try-python-master\.devcontainer\Dockerfile -t vsc-vscode-remote-try-python-master-486294f4d73f25a657ec08f53ff07d5f d:\Development\vscode-remote-try-python-master
Sending build context to Docker daemon 24.06kB
Step 1/13 : FROM python:3
---> 22a423a5db36
Step 2/13 : RUN pip install pylint
---> Running in 23380af29dd1
Successfully installed astroid-2.2.5 colorama-0.4.1 isort-4.3.20 lazy-object-proxy-1.4.1 mccabe-0.6.1 pylint-2.3.1 six-1.12.0 typed-ast-1.4.0 wrapt-1.11.1
Removing intermediate container 23380af29dd1
---> 5569fa48c9c5
Step 3/13 : ENV DEBIAN_FRONTEND=noninteractive
---> Running in 941086f674cb
Removing intermediate container 941086f674cb
---> b8b2fd47bdb1
Step 4/13 : RUN apt-get update && apt-get -y install --no-install-recommends apt-utils 2>&1
---> Running in defcc073adcf
At line:1 char:91
+ ... ; $ProgressPreference = 'SilentlyContinue'; apt-get update && apt-get ...
+ ~~
The token '&&' is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : InvalidEndOfLine
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; apt-get update && apt-get -y install --no-install-recommends apt-utils 2>&1' returned a non-zero code: 1
Failed: Building an image from the Dockerfile.
Command failed: C:\Program Files\Docker\Docker\Resources\bin\docker.exe build -f d:\Development\vscode-remote-try-python-master\.devcontainer\Dockerfile -t vsc-vscode-remote-try-python-master-486294f4d73f25a657ec08f53ff07d5f d:\Development\vscode-remote-try-python-master对其他人来说,这是一种普遍的体验吗?如有任何解决方案或建议,请进一步排除。
发布于 2019-07-02 06:00:40
正如本GitHub问题中所讨论的,这个问题似乎是由于使用Windows容器造成的。
是的,不幸的是,Windows容器是不支持的,在"Windows容器模式“中使用LCOW用于Desktop并不是我们现在真正支持的东西,考虑到它的实验状态。 LCOW仍然存在一些空白,比如支持单个文件绑定安装,这可能会导致问题,并且像PostgreSQL这样的东西还不能工作。见这里和这里。 现在的Windows推荐主要是在异常的基础上使用LCOW: 何时使用Moby VM 现在,我们向以下人员推荐运行Linux容器的Moby VM方法:
何时使用LCOW
现在,我们向以下人士推荐LCOW:
https://stackoverflow.com/questions/56593805
复制相似问题