2

I would like to run a single command to attach to a running dev container in a remote ssh host. The current alternative is to use the GUI in the following way:

  • >Remote-SSH: Connect to Host... -> new window -> ssh auth 1
  • >Dev Containers: Attach to Running Container... -> ssh auth 2 -> select container -> new window -> ssh auth 3

I cannot skip the ssh auths since 2FA is enabled. Therefore I must wait some time in between each ssh auth which is not ideal. I know it is possible to connect directly to the running container because when the connection is broken, the window can reconnect directly to the running container without having to go through ssh auth 1 & 2. This means there is some kind of --file-uri that is stored within the window context and it allows it to connect directly.

I am looking for the documentation on how to combine these two commands suggested here and here

code --folder-uri "vscode-remote://ssh-remote+remote_server_goes_here/folder/on/remote/host/here

code --folder-uri="vscode-remote://dev-container%2B${hex}/workspaces/${base}"

I know the name and ID of my running container. So I have unsuccessfully tried:

code --folder-uri "vscode-remote://ssh-remote+<myhost>+attached-container+<mycontainerID>"
code --folder-uri "vscode-remote://ssh-remote+<myhost>+dev-container+<mycontainerID>/<myfolder>"

1 Answer 1

0

Unfortunately, a single command to attach to a running container on a remote (SSH) host is not supported by the current CLI code implementation.

I too have looked into doing the same. In my research the following links were the only official documentation relevant to this. However, both the attached-container and dev-container URI methods don't seem to be officially documented.

https://code.visualstudio.com/docs/editor/command-line

https://code.visualstudio.com/docs/remote/ssh#using-a-development-container-on-the-remoteshost


I have submitted a feature request via the vscode GitHub repository, which has been accepted as a candidate for the backlog. If you agree that this could be a useful feature, upvote (+1/"👍") the issue description on GitHub to help promote it to the backlog so it can be implemented.

Link to GitHub feature-request issue


As the official documentation relevant to the OP's question is insufficient, this could be considered a duplicate of CLI code command to attach VS Code to a running container on a remote SSH host (Dev Containers over Remote - SSH in VS Code)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.