Reputation: 546
I am looking for a way to open Visual Studio Code using the CLI and attach it directly to a container running instead of using GUI.
Example:
vscode <my-running-container>
Thanks:)
Upvotes: 4
Views: 140
Reputation: 1
Assuming that your container is running locally, you can do this with the following process:
--detach
flag along with the docker run
command, the full container ID is returned.vscode-remote://
.Here is an example implementation using commonly available commands:
HEX_CONTAINER_ID=$(echo -n $CONTAINER_NAME_OR_ID | od -A n -t x1 | tr -d ' \n')
code --folder-uri="vscode-remote://attached-container+$HEX_CONTAINER_ID/$WORKDIR"
Upvotes: 0