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:
- switching between Linux and Windows containers
- swapping between PowerShell, Git Bash, and WSL (Ubuntu) as the default shell for Visual Code (
terminal.integrated.shell.windows
) - using one of the other Remote-Container examples from Microsoft
- creating a very basic project with one simple Python file and attempting the
Remote-Containers: Open Folder in Container...
again, selectingpython:3
as the targeted Docker image
None 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.