Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev container based on compose file does not start up from WSL. #671

Closed
spiner2000 opened this issue Nov 1, 2023 · 4 comments
Closed

Dev container based on compose file does not start up from WSL. #671

spiner2000 opened this issue Nov 1, 2023 · 4 comments

Comments

@spiner2000
Copy link

Got the following error:
Error running command remote-containers.newContainer: Command failed: /home/master/.vscode-server/bin/f1b07bd25dfad64b0167beb15359ae573aecd2cc/node /home/master/.vscode-remote-containers/dist/dev-containers-cli-0.315.1/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-compose-path docker compose --workspace-folder /home/master/dev/test --log-level debug --log-format json --config /home/master/dev/test/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root. This is likely caused by the extension that contributes remote-containers.newContainer.

dev container log:

[106572 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[106670 ms] 1.43
[106671 ms] Start: Run in Host: wslpath -w /home/master/dev/test
[106716 ms] Start: Run in Host: /home/master/.vscode-server/bin/f1b07bd25dfad64b0167beb15359ae573aecd2cc/node /home/master/.vscode-remote-containers/dist/dev-containers-cli-0.315.1/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-compose-path docker compose --workspace-folder /home/master/dev/test --log-level debug --log-format json --config /home/master/dev/test/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root
[106992 ms] @devcontainers/cli 0.51.3. Node.js v18.15.0. linux 5.15.90.1-microsoft-standard-WSL2 x64.
[106992 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/master/dev/test --filter label=devcontainer.config_file=/home/master/dev/test/.devcontainer/devcontainer.json
[107110 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=/home/master/dev/test
[107230 ms] Start: Run: docker compose version --short
[107294 ms] Error: spawn docker compose EACCES
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
[107302 ms] Exit code 1

what i have done:
I created the empty project folder with template https://github.com/devcontainers/templates/tree/main/src/postgres inside freshly installed WSL Ubuntu 22.04
Docker desktop was reseted to factory defaults. v4.25.0 WSL Integration was enabled.

Dev cont ext version v0.315.1
VS Code version

Version: 1.83.1 (user setup)
Commit: f1b07bd25dfad64b0167beb15359ae573aecd2cc
Date: 2023-10-10T23:48:05.904Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045

this issue related only to compose based containers with sources inside WSL.
Don't know what was happened and triggered this error, a couple days ago everything worked fine.

@samruddhikhandale
Copy link
Member

Hi 👋

This issue looks very similar to #650.

What is your docker version? Can you try upgrading and testing the same flow? Thanks

@spiner2000
Copy link
Author

spiner2000 commented Nov 2, 2023

Hello!

Client: Docker Engine - Community
 Cloud integration: v1.0.35+desktop.5
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:32:16 2023
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Desktop
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:32:16 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

compose:
    2.23.0-desktop.1

I've seen #650 issue. I have the latest one version of docker and compose plugin. I tried to run it inside fresh Ubuntu 23 and 22 over WSL but I have the same result.
But if I make dev container from this template and don't link it to the directory inside WSL - it works.
If I change the devcontainer.json to Dockerfile based it works regardless of WSL linkage.

There is something happened between compose and wsl which is not cleaned by Docker's "Reset to factory defaults" button.
Unfortunately logs are very limited to figure out what is wrong.

@spiner2000
Copy link
Author

Hello! I checked if the issue present in insiders version of VS Code and find out that all works fine. The issue was resolved by uninstalling vscode completely, wiping out AppData\Roaming\Code folder and reinstalling VS Code back.

@Vynce
Copy link

Vynce commented Jun 25, 2024

I ran into this same issue and tracked it down to a permissions issue with /mnt/c/WINDOWS/system32/config/systemprofile/.dnx/bin in my $PATH.

devcontainers/cli tries to run docker-compose via exec() to see if it exists. exec() runs commands via /bin/sh (which is a symlink to dash in Ubuntu). It iterates through all the paths in $PATH looking for docker-compose. If docker-compose isn't found, it'll return a /bin/sh: 1: docker-compose: not found error (which is expected in this case). If runs into an inaccessible path, it returns a /bin/sh: 1: docker-compose: Permission denied error.

This can be reproduced in WSL directly with /bin/sh -c "docker-compose". I used echo $PATH | tr ':' '\0' | xargs -0 ls -ld in a WSL shell to evaluate all the paths in $PATH and found one with a permissions issue.

/mnt/c/WINDOWS/system32/config/systemprofile/.dnx/bin was the bad path causing the issues. One of the parent paths doesn't have read permission, which causes the error:

$ ls -ld /mnt/c/WINDOWS/system32/config
ls: /mnt/c/WINDOWS/system32/config: Permission denied
d--x--x--x 1 user user 4096 Jun 20 18:32 /mnt/c/WINDOWS/system32/config

Removing C:\WINDOWS\system32\config\systemprofile\.dnx from the PATH env var on the Windows side fixed this issue for me.

#826 should mostly fix this specific issue by looking for docker compose before docker-compose, but there's still a risk of having a bad path early in $PATH.

There are several related issues in the WSL project:
microsoft/WSL#8100
microsoft/WSL#2779
microsoft/WSL#3886

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants