Launch VSCode into devcontainer session

Viewed 191

It appears that the only way to run devcontainers locally is by following these steps:

  1. Open your codebase in VSCode
  2. Reopen VSCode / The application in a devcontainer via command or the "Reopen in Container" popup

I would like to skip step 1 and launch VSCode directly into a container session. Is this currently possible?

2 Answers

This is now officially supported in the devcontainer CLI.

After installing the CLI, the project can be opened directly in a devcontainer using the command:

devcontainer open .

According to this Issue you can call the code command with according arguments, e.g. from your project folder (on a Mac)

p=$(echo -n "$PWD"|xxd -p -c 256) && code --folder-uri "vscode-remote://dev-container+${p/[[:space:]]/}/workspace"

(where /workspace ist the remote workspace folder)

For more information see the issue.

Related