14

I regularly open Visual Studio Code via code . and then have to click the Re-open in Container button.

Am I missing any shortcut to force it to do this from the command line?

Hastarin
  • 345
  • 1
  • 11
  • 4
    I'm looking for a way to do the same thing. The closest I've found, using Windows Process Monitor, is to identify the command line used by the Tasbar MRU. The MRU list seems to use: ```Code.exe --folder-uri "vscode-remote://dev-container%2B633a5c46696c65735c536f757263655c646174616f70732d70726f6a6563742d74656d706c617465/projects" ``` ... where '/projects' is the path that opens in the container. I do not know what the long GUID represents or either how to reproduce it or work around it. – aaronsteers Nov 14 '19 at 21:49
  • 1
    Ref on how to see what cli command was executed: https://superuser.com/questions/415360/how-do-i-find-out-command-line-arguments-of-a-running-program – aaronsteers Nov 14 '19 at 21:57
  • 1
    Another way to get that CLI: 1. Open code with `--log trace`. 2. Open remote container. Then close Code. 3. Look in your `logs` folder (platform-dependent, obvs!) for main.log. 4. Second line from bottom should look like: `onBeforeShutdown {"lastActiveWindow":{"folder":"vscode-remote://dev-container%2B7b22686f737450...` – FSCKur Feb 29 '20 at 13:20
  • 1
    I'm looking for a way to do the same thing. I think the best way in enable use a setting in a .code-workspace file. I made a [feature request](https://github.com/microsoft/vscode/issues/116698) in vscode GitHub project. – Alan Guedes Feb 15 '21 at 14:56

3 Answers3

4

You can open devcontainer directly with devcontainer CLI.

Install devcontainer CLI by running Remote-Containers: Install devcontainer CLI from VS Code. Then just run:

devcontainer open

in the same directory where you'd run code . and you will skip the Re-open step.

bh213
  • 6,343
  • 9
  • 43
  • 52
  • Thank you very much I didn't know this has been released. It's exactly the sort of thing I was after. It requires you install node and the extra package, so not ideal, but certainly better than the lack of options we'd had previously! – Hastarin May 07 '22 at 02:49
2

There is a way to do this GUIcally in Windows. I suspect this will also work for SSH / WSL workspaces.

  1. Open your dev container in VSCode as usual.
  2. Right-click on your VSCode taskbar icon; it should show you a jump list with MRU workspaces.
  3. Look for that [Dev Container] list item (mine shows localhost:2375 because that's my docker host). You might like to pin it.
  4. You can open directly into the dev container by clicking on that item.

enter image description here

FSCKur
  • 920
  • 7
  • 16
0

I have done this with ApiLogicServer - you build the .devcontainer file, plus the Dockerfile

val
  • 139
  • 1
  • 6