theother
theother

Reputation: 317

vscode jumps to a specific volume afer reopen in container

I have a nice project with a .devcontainer config. Since the vscode update to 1.63 I have some trouble with the docker setup. Now I'm using the newest 1.64.0

I just want to build a new container with a clean volume an start in a fresh environment.

What happens is, that a new container is starting and I see some stuff from another container. Same if I clone a git repo into a container volume.

  1. Why are some containers connected with the same volume for the workspace?
  2. Why do I fall back every time to the same volume?

In the devcontainer.json I set:

"workspaceFolder": "/workspace",
"workspaceMount": "source=remote-workspace,target=/workspace,type=volume",

Upvotes: 2

Views: 433

Answers (1)

Claudio
Claudio

Reputation: 3095

To build a new devcontainer in a fresh environment you can install devcotainer cli and trigger build manually.

I'm used to mount workspace as bind mount (on windows with wsl2 files) insted of volume mount, i think that the main issue is the volume name: if both project has "source=remote-workspace" the volume will be detected as the same.

With nodejs where I want to keep node_modules folder inside container, I have done a double mount following this official vscode guide for this usecase.

So I have left workspaceMount as a default bindmount than I have added a volue that override a specific folder.

{
  "mounts": [
    //      vvvvvvvvvvv name must be unique
    "source=projectname-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume"
  ]
}

The results is:

  • every file / is server by container
  • but all inside ${containerWorkspaceFolder} is served by bind mount
  • but all inside ${containerWorkspaceFolder}/node_modules is server by named volumes

Upvotes: 1

Related Questions