dockervisual-studio-codedocker-composevscode-devcontainerdevcontainer

Opening a second vscode devcontainer closes the first


I am developing with vscode devcontainers (Ubuntu 22.04).

I have one that I was doing development in (devA), and after team members made changes in the repository, I wanted to pull them in, but not modify devA at all. I created a fresh clone of the repository to build another devcontainer (devB) to see if there were any issues introduced with the code changes.

Directory Structure
 
desktop/
    devA/
       .devcontainer/
       ...
       ...
    new_folder/
       devB/
           .devcontainer/
           ...
           ...

Based on the vscode documentation, it looks like you should be able to open 1 devcontainer per vscode window. Right now, if I start one devcontainer, the other one will disconnect, or vscode will think that they are both the same devcontainer (ie when I open devB, it has uncommitted files from the workspace of devA). What are the settings/metadata that create the identity of the devcontainers and what could I change to have vscode treat them as 2 separate devcontainers?

I have tried changing the workspace name and 'name' in devcontainer.json but those did not resolve anything. Below I have my devcontainer.json

{
  "name": "Pose Dev Container",
  "dockerComposeFile": ["docker-compose.yaml"],
  "service": "pose", 
  "workspaceFolder": "/Pose",
  "forwardPorts": [3306],
  "postCreateCommand": "pip install ipykernel",
  "customizations": {

     "settings": {
        "python.pythonPath": "/usr/local/bin/python"
    },
    "vscode": {
        "extensions": [
            "ms-python.python",
            "ms-toolsai.jupyter"
        ]
    }

} }


Solution

  • I wanted to add an answer to go over the testing I did.

    I cloned 2 copies of the same repository and incrementally changed settings until I was able to open both copies independently.

    desktop/                    
      |                         
      |--cloneA/
      |   |--myrepo/       
      |   |   |--.devcontainer/     
      |   |     |--devcontainer.json
      |   |   |--docker-compose.yaml 
      |   |   |--...                             
      |--cloneB/
      |   |--myrepo/       
      |   |   |--.devcontainer/     
      |   |     |--devcontainer.json
      |   |   |--docker-compose.yaml 
      |   |   |--...    
    

    In order I:

    Only after renaming the repo name was I able to open 2 independent devcontainers of the same repo.