visual-studio-codevscode-remotevscode-devcontainer

How can I create a VS Code Dev Container given an existing volume?


My dev Container is gone, but the volume is still there. How can I create a new container with this volume as /workspaces mount? In the volume is a .devcontainer.json, which could be used to recreate the container. But how?


Solution

  • Create a local folder with a .devcontainer/devcontainer.json file and use a named volume:

    "workspaceMount": "source=your-volume-name-here,target=/workspace,type=volume",
    "workspaceFolder": "/workspace",
    

    Then run Dev Containers: Open Folder in Container... to connect to the container.

    If it's a workspace volume that contains multiple repos, then use the File > Open Folder... command to open the cloned repository in the container.