4

This is probably the most stupid question ever, but I can't find an easy way to do it.

I successfully attached VSCode to a running container in my machine. But now, each time I open VSCode, it's automatically attached to that container. Is there any way to detach it and just open VSCode?

EDIT: As you can see, each time I open VSCode insiders, it's automatically attached to a running container. It even starts the container if it's stopped

enter image description here

This is the menu I see when I try to run commands associated to remote-containers. I'm attached to a running docker container and cannot reopen the folder without being attached to that container.

No reopen folder unattached to running container

Yes, I'm using Remote Development Extension Pack + VSCode Insiders 1.35

These are the versions of VSCode Remote, Node and other relevant software components on my machine

enter image description here

So, how could I just detach VSCode insider from that container without deleting the container + the image?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jorge Arévalo
  • 2,858
  • 5
  • 36
  • 44

2 Answers2

2

Maybe the command Remote-Containers: Reopen Folder Locally is what your looking for.

makons
  • 522
  • 1
  • 11
  • 27
  • I don't have that option :-(. Using VSCode insider 1.35 – Jorge Arévalo May 22 '19 at 08:28
  • From your tag, I presume you are using [Remote Development extension](https://code.visualstudio.com/docs/remote/containers). Currently this is only supported for insiders version of the VSCode, so you might be referring to the version 1.35.0-insider, which I'm running as well. If all of the said is correct, you should be able to reveal the command search by `F1` and find `Remote-Containers: Reopen Folder Locally` command. If that's not the case, can you please elaborate a bit more. – makons May 28 '19 at 09:50
  • Thanks! Yes, I'm using that extension. And no, I cannot see that option. I've added a few screenshots to clarify. – Jorge Arévalo May 28 '19 at 15:39
0

The way to do this is by closing the workspace folder - that will detach the running container completely and close the existing project.

The next step would be to reopen the local source code folder. There is folder call .devcontainer - which contains a devcontainer.json file -

// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.122.1/containers/ubuntu
{
    "name": "Ubuntu",
    "build": {
        "dockerfile": "Dockerfile",
        // Update 'VARIANT' to pick an Ubuntu version. Rebuild the container 
        // if it already exists to update. Available variants: 18.04, 20.04
        "args": { "VARIANT": "18.04" }
    },

    // Set *default* container specific settings.json values on container create.
    "settings": { 
        "terminal.integrated.shell.linux": "/bin/bash"
    },

    // Add the IDs of extensions you want installed when the container is created.
    "extensions": []

    // Use 'forwardPorts' to make a list of ports inside the container available locally.
    // "forwardPorts": [],

    // Use 'postCreateCommand' to run commands after the container is created.
    // "postCreateCommand": "uname -a",

    // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
    // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

    // Uncomment when using a ptrace-based debugger like C++, Go, and Rust
    // "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

    // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
    // "remoteUser": "vscode"
}

Deleting this will also detach a running container - you can even modify the docker container to the one you desire and rebuild it again.

Magnus Melwin
  • 1,509
  • 1
  • 21
  • 32