Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to launch Visual Studio Code and force it to open in a Remote Container?

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?

like image 232
Hastarin Avatar asked Nov 13 '19 00:11

Hastarin


People also ask

How do I connect to VS Code remote container?

To attach to a Docker container, either select Remote-Containers: Attach to Running Container... from the Command Palette (F1) or use the Remote Explorer in the Activity Bar and from the Containers view, select the Attach to Container inline action on the container you want to connect to.

How do I open a VS Code container?

Opening a terminal in a container from VS Code is simple. Once you've opened a folder in a container, any terminal window you open in VS Code (Terminal > New Terminal) will automatically run in the container rather than locally.

Can I run Visual Studio in a Docker container?

You can install Visual Studio Build Tools into a Windows container to support continuous integration and continuous delivery (CI/CD) workflows. This article guides you through what Docker configuration changes are required as well as what workloads and components you can install in a container.

How do I run a Visual Studio project in Docker?

Open the project in Visual Studio, and choose one of the following options: Select Docker Support from the Project menu. Right-click the project in Solution Explorer and select Add > Docker Support.


2 Answers

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

like image 53
FSCKur Avatar answered Nov 16 '22 02:11

FSCKur


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.

like image 31
bh213 Avatar answered Nov 16 '22 04:11

bh213