question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`devcontainer exec` tries to use different container than the response of `devcontainer up` in WSL

See original GitHub issue

devcontainer exec tries to use different container than the response of devcontainer up.

$ devcontainer up --workspace-folder .
[14 ms] @devcontainers/cli 0.12.1.
{"outcome":"success","containerId":"66d0453b1f8340282242c2efeff1e79af03734b45d56cfc7630b5b92b108880e","composeProjectName":"masked","remoteUser":"vscode","remoteWorkspaceFolder":"/workspace"}
$ devcontainer exec --workspace-folder . pwd
Shell server terminated (code: 1, signal: null)

Error response from daemon: Container 7a07354654d1bc329e8ba1ba2721582171fe483c541e5ee65f042c9dc6d7fe4f is not running

{"outcome":"error","message":"An error occurred running a command in the container.","description":"An error occurred running a command in the container."}

Version info: devcontainer@0.12.1 /home/sarisia/.asdf/installs/nodejs/18.5.0/.npm/lib/node_modules/@devcontainers/cli

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jbcpollakcommented, Oct 25, 2022

I had this problem when first trying this project out, with this process:

  • Started VS Code and launched my dev container
  • did a Git pull - at this point the running dev container was out of date but still running
  • ran devcontainer up --workspace-folder ., which reported success:
❯ devcontainer up --workspace-folder .
[30 ms] @devcontainers/cli 0.22.0. Node.js v16.6.1. linux 5.10.60.1-microsoft-standard-WSL2 x64.
Running the initializeCommand from devcontainer.json...

[95 ms] Start: Run: /bin/sh -c .devcontainer/setup_container.sh

{"outcome":"success","containerId":"33db7e5053ce8679a3e55b5536a8596996899a09036eb31f51d7aa58b5d3f791","composeProjectName":"project_devcontainer","remoteUser":"1000","remoteWorkspaceFolder":"/home/project"}
  • ran devcontainer exec --workspace-folder . /bin/bash and got this:
❯ devcontainer exec --workspace-folder . /bin/bash
Error: Dev container not found.
    at bailOut (/home/jpollak/.nodenv/versions/16.6.1/lib/node_modules/@devcontainers/cli/dist/spec-node/singleContainer.js:385:11)
    at doExec (/home/jpollak/.nodenv/versions/16.6.1/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:807:43)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async exec (/home/jpollak/.nodenv/versions/16.6.1/lib/node_modules/@devcontainers/cli/dist/spec-node/devContainersSpecCLI.js:741:20)
{"outcome":"error","message":"Dev container not found.","description":"An error occurred running a command in the container."}

Manually stopping the container, rebuilding it using the CLI and relaunching, then starting VS Code and separately running devcontainer exec ... seems to work.

If the container is launched first via VS Code, devcontainer exec ... cannot find the container.

The workaround I’ve found is to manually stop the devcontainer (if it was built with VSCode) then run: devcontainer up --remove-existing-container --workspace-folder . and finally: devcontainer exec --workspace-folder . /bin/bash

My goal is for my team to be able to use VSCode or the CLI/Terminal interchangeably with the same container.

using the explicit --container-id parameter on the exec command seems to work around this, although I still have trouble with #246

0reactions
chrmarticommented, Oct 26, 2022

The extension is using the UNC path for "devcontainer.local_folder", so it can distinguish between the same folder in different WSL distributions. The CLI inside a distribution is not aware of this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add option to allow running devcontainer inside a WSL2 ...
So my suggestion is to add an option in "Remote - Containers" that translate the Windows Path to WSL mount path using the...
Read more >
Visual Studio Code Dev Containers Frequently Asked Questions
Dev Containers FAQ. This article includes some of the common questions for getting the Dev Containers extension up and running in different environments....
Read more >
VS Code Remote / GitHub Codespaces Development ...
Development container images for use with VS Code Remote - Containers and GitHub ... Their contents, and corresponding devcontainer.json files are typically ...
Read more >
How to copy files from local machine to docker container on ...
Use docker cp . docker cp c:\path\to\local\file container_name:/path/to/target/dir/. If you don't know what's the name of the container, ...
Read more >
Run GUI app in linux docker container on windows host
I wanted to be able to use the Evolution mail client and other handy ... If I open a terminal into the container...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found