microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 292 forks source link

Container reopened from Remote-SSH not stopping after closing the window #6056

Open Uguudei opened 2 years ago

Uguudei commented 2 years ago

Dev containers that reopened from the Remote-SSH extension are kept running after closing the window. It should be stopped as how opening a container in cloned volume does.

I have even tried setting "shutdownAction": "stopContainer" in devcontainer.json, however, it didn't help.

Steps to Reproduce:

  1. Open repo on Remote host SSH
  2. Reopen in Containers
  3. Successful opens/builds containers
  4. Close VS Code window.
felipecrs commented 2 years ago

I can also confirm this issue. It happens with both Dockerfile and docker-compose (when using shutdownAction: stopCompose.

leohxj commented 2 years ago

Now I manual stop container as workaround. it maybe not urgent.

AlexanderPashuk commented 2 years ago

Is there any workaround before a fix will be available?

armaanPy commented 2 years ago

@chrmarti Is there any ETA on this fix?

cyangle commented 2 years ago

I have been using my workaround for quite a while.

https://github.com/microsoft/vscode-remote-release/issues/3512#issuecomment-991473473

SmallhillCZ commented 1 year ago

I have been using my workaround for quite a while.

#3512 (comment)

But this stops only the main container, not other containers from docker compose, right?

SmallhillCZ commented 1 year ago

And yes, the issue is still there in 2023…

@chrmarti is there any ETA on this? The May 2022 milestone is not valid anymore I assume.

SmallhillCZ commented 1 year ago

This issue should be solved with https://github.com/microsoft/vscode-remote-release/issues/7754

jahed commented 1 year ago

This issue should be solved with #7754

Doesn't look like it. I'm still encountering this issue on VS Code v1.78.2, Dev Containers v0.292.0, Remote SSH v0.102.0.

SmallhillCZ commented 1 year ago

Try the pre-release version (v0.294.0), it works for me okay. Also you have to wait like 10 seconds before the containers get stopped.

jahed commented 1 year ago

Try the pre-release version (v0.294.0), it works for me okay. Also you have to wait like 10 seconds before the containers get stopped.

Tried that, no change. It's possible the fix you're referring to only fixed it for stopCompose and not for stopContainer. It's difficult to know since #7754 doesn't have a PR linked to it.

SmallhillCZ commented 1 year ago

Maybe 🤷‍♀️

3f6a commented 1 year ago

I have "shutdownAction": "stopContainer", in my devcontainer.json file for a Github Codespaces container. But the codespace does not stop running when I close the vscode window.

Any chance this gets fixed?

thebhef commented 1 year ago

I think I'm seeing this issue or a related one. I have two containers running with docker-compose and everything is basically working as desired, except for the docker-compose stop.

OS: Win11 23H2 22621.2283 VSCode: 1.82.2 Devcontainer: 0.309.0 Docker Desktop version: 4.23.0 Docker: 24.0.6 Docker-compose: 2.21.0-desktop.1 WSL version: 1.2.5.0 WSL OS: Ubuntu 20.04.5

I can see in the log that the stop is attempted, but it fails and I can't get it to tell me why.

[2023-09-29T16:53:38.768Z] Cleaning up after 23186 ms...
[2023-09-29T16:53:38.768Z] Delaying for 10000 ms.
[2023-09-29T16:53:48.781Z] Start: Run in container: /bin/sh
[2023-09-29T16:53:48.809Z] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
[2023-09-29T16:53:48.986Z] Stop (177 ms): Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd || echo ; readlink /proc/$pid/ns/mnt || echo ; cat /proc/$pid/stat | tr "
[2023-09-29T16:53:48.988Z] Start: Run: docker-compose --project-name devcontainer -f /mnt/wsl/docker-desktop-bind-mounts/Ubuntu/5733c52769e8a47bdf73664b055191686ccbcda35160d7f4bae7ebab630bf052/devcontainer/docker-compose.yml stop -t 0
[2023-09-29T16:53:49.048Z] Stop (60 ms): Run: docker-compose --project-name devcontainer -f /mnt/wsl/docker-desktop-bind-mounts/Ubuntu/5733c52769e8a47bdf73664b055191686ccbcda35160d7f4bae7ebab630bf052/devcontainer/docker-compose.yml stop -t 0
[2023-09-29T16:53:49.048Z] Unexpected error: Command failed: docker-compose --project-name devcontainer -f /mnt/wsl/docker-desktop-bind-mounts/Ubuntu/5733c52769e8a47bdf73664b055191686ccbcda35160d7f4bae7ebab630bf052/devcontainer/docker-compose.yml stop -t 0
[2023-09-29T16:56:26.248Z] Stop (157467 ms): Run in container: /bin/sh

The command is successful with no changes when I copy it from this log and execute it in WSL myself, and sudo is not required. I have dev.containers.executeInWSL=true

I've tried turning up the logging level to trace to see if I could get the output of the failing docker-compose command but the 'unexpected error' line hasn't changed.

themw123 commented 1 year ago

I am getting following error with f1 of Dev Containers Developer: Show Alll Logs

Unexpected error: Error: Exectuable 'docker' not found on PATH '.....' at cs (c:\Users\Marvin.vscode\extensions\ms-vscode-remote.remote-containers-0.315.1\dist\shutdown\shutdownMonitorProcess.js:29:1355) at async c:\Users\Marvin.vscode\extensions\ms-vscode-remote.remote-containers-0.315.1\dist\shutdown\shutdownMonitorProcess.js:30:550 at async Mt (c:\Users\Marvin.vscode\extensions\ms-vscode-remote.remote-containers-0.315.1\dist\shutdown\shutdownMonitorProcess.js:23:3480) at async Zg (c:\Users\Marvin.vscode\extensions\ms-vscode-remote.remote-containers-0.315.1\dist\shutdown\shutdownMonitorProcess.js:30:3446) at async rw (c:\Users\Marvin.vscode\extensions\ms-vscode-remote.remote-containers-0.315.1\dist\shutdown\shutdownMonitorProcess.js:30:6189) at async c:\Users\Marvin.vscode\extensions\ms-vscode-remote.remote-containers-0.315.1\dist\shutdown\shutdownMonitorProcess.js:30:5424

I am using devcontainers with a remote connection to my linux server.

GlacierFox commented 8 months ago

Getting this same problem also with "shutdownAction": "stopContainer". I'm having to manually stop hanging containers after a while before my system gets choked up.

JtMotoX commented 1 week ago

Here is a workaround I have come up with. It is less than ideal but it has been almost 3 years that this issue has been open and still no word on a fix.

.devcontainer

{
    ...
    "postCreateCommand": "while true; do sleep 20; ps aux | grep -E 'vscode.*[b]ootstrap-fork.*extensionHost.*' > /dev/null || kill -15 1; done",
    "runArgs": [
        "--rm"
    ]
    ...
}

This particular dev container does not have a Dockerfile. If you have a Dockerfile, you can probably refer to https://github.com/microsoft/vscode-remote-release/issues/3512#issuecomment-2131354971