首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打开带有远程容器的文件夹失败,原因是PowerShell用于执行Dockerfile构建步骤

打开带有远程容器的文件夹失败,原因是PowerShell用于执行Dockerfile构建步骤
EN

Stack Overflow用户
提问于 2019-06-14 07:54:09
回答 1查看 270关注 0票数 0

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

初始化过程开始的很好,通过一些码头建设没有问题。Dockerfile中的步骤1-3成功,然后步骤4(Dockerfile的13/14行)抛出一个异常并退出,因为RUN命令包含一个AND_IF操作符(&&)。这是因为它被作为子命令传递给不支持PowerShell的&&

我遵循使用说明来准备使用远程容器功能的系统,包括将我的驱动器(C:和D:)添加到共享驱动器中。

到目前为止,我尝试过解决以下问题:

  • Linux和Windows容器之间的切换
  • PowerShell、Git和WSL (Ubuntu)之间的交换作为视觉代码(terminal.integrated.shell.windows)的默认外壳
  • 使用Microsoft的其他远程容器示例之一。
  • 使用一个简单的Python文件创建一个非常基本的项目,然后再次尝试Remote-Containers: Open Folder in Container...,选择python:3作为目标Docker映像

上述任何步骤都没有产生任何不同的结果。

Docker检查显示,Config->Shell设置为:

代码语言:javascript
复制
"Shell":
  [
    "powershell",
    "-Command",
    "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"
  ]

Config->Cmd设置为:

代码语言:javascript
复制
"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安装扁平化):

代码语言:javascript
复制
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

对其他人来说,这是一种普遍的体验吗?如有任何解决方案或建议,请进一步排除。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-02 06:00:40

正如本GitHub问题中所讨论的,这个问题似乎是由于使用Windows容器造成的。

是的,不幸的是,Windows容器是不支持的,在"Windows容器模式“中使用LCOW用于Desktop并不是我们现在真正支持的东西,考虑到它的实验状态。 LCOW仍然存在一些空白,比如支持单个文件绑定安装,这可能会导致问题,并且像PostgreSQL这样的东西还不能工作。见这里这里。 现在的Windows推荐主要是在异常的基础上使用LCOW: 何时使用Moby VM 现在,我们向以下人员推荐运行Linux容器的Moby VM方法:

  • 想要一个稳定的容器环境。这是Windows默认设置的Docker。
  • 运行Windows或Linux容器,但很少同时运行。
  • Linux容器之间有复杂的或自定义的网络需求。
  • 不需要Linux容器之间的内核隔离(Hyper隔离)。

何时使用LCOW

现在,我们向以下人士推荐LCOW:

  • 想测试我们的最新技术。
  • 同时运行Windows和Linux容器。
  • 需要Linux容器之间的内核隔离(Hyper隔离)。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56593805

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档