Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remote-Container Bug]: Opening the same Docker image as a different user closes the first running instance #10078

Closed
GarbenTangheVintecc opened this issue Jul 19, 2024 · 2 comments
Assignees
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster

Comments

@GarbenTangheVintecc
Copy link

GarbenTangheVintecc commented Jul 19, 2024

Let me tell the story, including the steps to reproduce the bug and some logs.

  1. Some Context

We use a remote server that runs Ubuntu 22.04 and has 2 user accounts: user1 (UID=1001) and user2 (UID=1002).

Our codebase contains the following files:

# .devcontainer/Dockerfile
FROM ubuntu:22.04

# Create User
RUN useradd --create-home --user-group --uid 5000 user
ENV USER=user
USER user
WORKDIR /home/user

ENTRYPOINT [ "/usr/bin/bash" ]
# .devcontainer/docker-compose.yaml
services:

  mono:
    image: mono_dev_x86_64_ubuntu_22.04
    build:
      context: ..
      dockerfile: .devcontainer/Dockerfile
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    user: user
    volumes:
      - ..:/home/user/mono
    network_mode: host
// .devcontainer/devcontainer.json
{
  "dockerComposeFile": "docker-compose.yaml",
  "name": "mono_test",
  "service": "mono",
  "updateRemoteUserUID": true,
  "workspaceFolder": "/home/user/mono"
}
  1. What Works

My colleague (user1) connects with his Ubuntu 22.04 laptop through SSH with the server on his account.

$ id
uid=1001(user1) gid=1041(user1)

He opens our codebase in a devcontainer.

$ id
uid=1001(user) gid=1041(user)

Note that the UID of the user inside the container updated correctly from 5000 to 1001.

  1. What Does Not Work

I (user2) connect with my Ubuntu 24.04 laptop through SSH with the same server but on my account.

$ id
uid=1002(user2) gid=1042(user2)

I also open a devcontainer but starting from my copy of the codebase.

$ id
uid=1002(user) gid=1042(user)

Note that the UID of the user inside the container updated correctly from 5000 to 1002.

My colleague now sees this pop-up on his open VS Code window.
image

When he reloads the window, the ID in his container changed to mine:

$ id
uid=1002(user) gid=1042(user)

We only see one container running, so he effectively connected with my running container.
His container is closed. This is problematic because my colleague loses all his work in the original devcontainer, as soon as I try to open the same container from my copy of the codebase.

  • VSCode Version: 1.91.0
  • Local OS Version: Ubuntu 22.04/24.04 LTS
  • Remote OS Version: Ubuntu 22.04 LTS
  • Remote Extension/Connection Type: Containers
  • Remote SSH Version: 0.112.0

Does this issue occur when you try this locally?: Yes
Does this issue occur when you try this locally and all extensions are disabled?: Yes

Related to #8974, #7738, #7068, #2677, and #2456.

@vscodenpa vscodenpa added the containers Issue in vscode-remote containers label Jul 19, 2024
@chrmarti
Copy link
Contributor

This looks like Docker Compose using the same project name for both. You could change the project folder name (from which the Docker Compose project name is derived) or include the user name in the project name by adding name as a top-level property in your docker-compose.yml:

name: myproject_devcontainer_${USER}

@chrmarti chrmarti added the info-needed Issue requires more information from poster label Jul 19, 2024
@GarbenTangheVintecc
Copy link
Author

Indeed, this fixed the issue!

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
containers Issue in vscode-remote containers info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants