I was hoping to test out the new Remote Development extension using the Remote-Containers functionality. I grabbed the sample Python project and opened it using the Remote-Containers: Open Folder in Container...
function.
The initialisation process kicks off fine, stepping through some of the Docker build without problem. Steps 1-3 in the Dockerfile succeed and then step 4 (lines 13/14 of the Dockerfile) throws an exception and exits because the RUN
command includes an AND_IF
operator (&&
). This is because it's being passed as a subcommand to PowerShell which doesn't support &&
.
I've followed the instructions for preparing my system for using the Remote-Containers functionality, including adding both my drives (C: and D:) to the Shared Drives.
Troubleshooting I've tried so far:
terminal.integrated.shell.windows
)Remote-Containers: Open Folder in Container...
again, selecting python:3
as the targeted Docker imageNone of the above steps have produced any different outcomes.
Docker Inspect reveals that the Config
->Shell
setting is:
"Shell":
[
"powershell",
"-Command",
"$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"
]
while the Config
->Cmd
setting is:
"Cmd":
[
"powershell",
"-Command",
"$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';",
"apt-get update && apt-get -y install --no-install-recommends apt-utils 2>&1"
]
The full container config is here.
The reason for the exception is obvious but I can't discern why the Dockerfile RUN
instruction is being passed to PowerShell like above.
I'm running Visual Studio Code - Insiders (1.36.0-insider) and Docker Engine 18.09.2 on Windows 10 (1809).
The exception produces the following error when step 4 fails (I've included the preceding successful steps for context; flattened the pip install in step 2 for brevity):
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
Is this a common experience for anyone else? Would appreciate any solutions or suggestions for troubleshooting further.
This issue seemingly results from the use of Windows Containers, as discussed in this GitHub issue.
Yeah, unfortunately Windows Containers are not supported and using LCOW in "Windows Containers mode" for Docker Desktop is not something we really support right now given its experimental state.
LCOW still has gaps like supporting single file bind mounting that can cause issues and things like PostgreSQL are called out as not working yet. See here and here.
The Windows recommendation right now is primarily to use LCOW on an exception basis:
When to use Moby VM
Right now, we recommend the Moby VM method of running Linux containers to people who:
- Want a stable container environment. This is the Docker for Windows default.
- Run Windows or Linux containers, but rarely both at the same time.
- Have complicated or custom networking requirements between Linux containers.
- Don't need kernel isolation (Hyper-V isolation) between Linux containers.
When to use LCOW
Right now, we recommend LCOW to people who:
- Want to test our newest technology.
- Run Windows and Linux containers at the same time.
- Need kernel isolation (Hyper-V isolation) between Linux containers.