microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.22k stars 518 forks source link

Docker extension repeatedly uninstalls itself, then won't connect when installed #4389

Closed mark-turner closed 1 month ago

mark-turner commented 1 month ago

I have repeatedly installed Docker extension version 1.29.2 in VS Code Version 1.93.1 on macOS Sonoma 14.6.1 on M1 hardware. It works for a short while (less than an hour), then at some point disappears from the VS Code sidebar and the following message reappears:

"Do you want to install the recommended 'Docker' extension from Microsoft for the Docker language?"

After agreeing to reinstall, I get the message "Docker is not installed. Would you like to learn more about installing Docker?" even though Docker is installed and running the whole while this is going on.

The issue sounds similar to https://github.com/microsoft/vscode-docker/issues/4317 and https://github.com/microsoft/vscode-docker/issues/4227 which were both closed without resolution.

I have tried manually setting the docker executable path as described here, but it makes no difference.

When the extension is reinstalled an running, I get this message, even though Docker Desktop is running and the container is running:

Screenshot 2024-09-24 at 16 33 34

Screenshot 2024-09-24 at 16 35 04

This is a new issue, as I have been running Docker and the Docker Extension without problems until recently.

bwateratmsft commented 1 month ago

The extension uninstalling itself is definitely a VSCode issue--that absolutely should not be happening. I'll file a VSCode issue for that one.

For the other issue--not detecting that Docker is installed even though it is--is there anything in the Output tab -> "Docker" output log?

bwateratmsft commented 1 month ago

Created https://github.com/microsoft/vscode/issues/229566 for the self-uninstall issue.

mark-turner commented 1 month ago

Hi @bwateratmsft thanks for your help! The Output tab is empty. So is the Problems tab. But the terminal tab is actually connected and logged in to the docker workspace volume. I can run commands there, even though the Docker extension thinks there is no connection.

Screenshot 2024-09-24 at 21 19 14

bwateratmsft commented 1 month ago

Is this using a remote connection like SSH remoting? Or Dev Containers?

mark-turner commented 1 month ago

No, the container is running locally on the same computer.

On Tue, Sep 24, 2024 at 21:30 Brandon Waterloo [MSFT] < @.***> wrote:

Is this using a remote connection like SSH remoting https://code.visualstudio.com/docs/remote/ssh?

— Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode-docker/issues/4389#issuecomment-2372192042, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFOPXATN3DCG5JNFNIEIGNTZYG4WJAVCNFSM6AAAAABOYPDAPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZSGE4TEMBUGI . You are receiving this because you authored the thread.Message ID: @.***>

bwateratmsft commented 1 month ago

If you open a terminal in VSCode on the host machine (not the terminal attached to the container), and execute a Docker command like docker -v, what do you see?

mark-turner commented 1 month ago

I see this:

[Wed Sep 25 13:49] ~ $ docker -v
Docker version 27.2.0, build 3ab4256
bwateratmsft commented 1 month ago

This is probably the endless Mac PATH environment variable issue then. Can you try the following to see if the PATH contains what it's supposed to?

  1. In the terminal, run which docker and share the path that it says Docker is located at.

  2. In VSCode, go to the Output tab, and then to Docker's output log.

  3. Click the little gear icon next to the dropdown, and change Docker's output log level to Trace.Image

  4. This should output a bunch of information and environment variables, etc. Please redact whatever you need to but share what you can from that output.

mark-turner commented 1 month ago

Hi @bwateratmsft. My docker binary is located at /usr/local/bin/docker FYI, I changed the Docker Path setting to this (from just "docker") but it made no difference.

Screenshot 2024-09-25 at 18 41 12

Here is the trace output:

2024-09-24 14:32:52.377 [error] Failed to set up event listener: spawn docker ENOENT
2024-09-25 16:36:33.024 [debug] --- Process Environment (28) ---
2024-09-25 16:36:33.024 [debug] NODE_VERSION: 20.17.0
2024-09-25 16:36:33.024 [debug] HOSTNAME: xyz
2024-09-25 16:36:33.024 [debug] YARN_VERSION: 1.22.22
2024-09-25 16:36:33.024 [debug] HOME: /root
2024-09-25 16:36:33.024 [debug] NVM_SYMLINK_CURRENT: true
2024-09-25 16:36:33.024 [debug] NVM_DIR: /usr/local/share/nvm
2024-09-25 16:36:33.024 [debug] PATH: /usr/local/share/nvm/current/bin:/usr/local/share/nvm/versions/node/v20.17.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2024-09-25 16:36:33.024 [debug] VSCODE_AGENT_FOLDER: /root/.vscode-server
2024-09-25 16:36:33.024 [debug] SHELL: /bin/bash
2024-09-25 16:36:33.024 [debug] PWD: xyz
2024-09-25 16:36:33.024 [debug] VSCODE_CWD: xyz
2024-09-25 16:36:33.024 [debug] VSCODE_NLS_CONFIG: {"userLocale":"en","osLocale":"en","resolvedLanguage":"en","defaultMessagesFile":"/vscode/vscode-server/bin/linux-arm64/xyz/out/nls.messages.json","locale":"en","availableLanguages":{}}
2024-09-25 16:36:33.024 [debug] VSCODE_HANDLES_SIGPIPE: true
2024-09-25 16:36:33.024 [debug] VSCODE_AMD_ENTRYPOINT: vs/workbench/api/node/extensionHostProcess
2024-09-25 16:36:33.024 [debug] VSCODE_HANDLES_UNCAUGHT_ERRORS: true
2024-09-25 16:36:33.024 [debug] NVM_INC: /usr/local/share/nvm/versions/node/v20.17.0/include/node
2024-09-25 16:36:33.024 [debug] REMOTE_CONTAINERS_IPC: /tmp/vscode-remote-containers-ipc-xyz.sock
2024-09-25 16:36:33.024 [debug] REMOTE_CONTAINERS_SOCKETS: ["/tmp/vscode-ssh-auth-xyz.sock"]
2024-09-25 16:36:33.024 [debug] SHLVL: 1
2024-09-25 16:36:33.024 [debug] NVM_CD_FLAGS: 
2024-09-25 16:36:33.025 [debug] NVM_BIN: /usr/local/share/nvm/versions/node/v20.17.0/bin
2024-09-25 16:36:33.025 [debug] _: /usr/bin/cat
2024-09-25 16:36:33.025 [debug] SSH_AUTH_SOCK: /tmp/vscode-ssh-auth-xyz.sock
2024-09-25 16:36:33.025 [debug] REMOTE_CONTAINERS: true
2024-09-25 16:36:33.025 [debug] BROWSER: /vscode/vscode-server/bin/linux-arm64/xyz40/bin/helpers/browser.sh
2024-09-25 16:36:33.025 [debug] ELECTRON_RUN_AS_NODE: 1
2024-09-25 16:36:33.025 [debug] VSCODE_IPC_HOOK_CLI: /tmp/vscode-ipc-xyz.sock
2024-09-25 16:36:33.025 [debug] VSCODE_L10N_BUNDLE_LOCATION: 
2024-09-25 16:36:33.025 [debug] --- Docker Environment (0) ---
danegsta commented 1 month ago

That particular setting only controls the behavior for the Dev Containers extension; can you try updating the docker.dockerPath setting as well and see if that works?

SusanWhiteUTK commented 1 month ago

I am following this thread as I have the same issue. I have updated the docker.dockerPath everywhere it was showing as an option in vscode. My setup is an M1 ultra on Sonoma 14.6.1. Open to any additional suggestions please. To clarify, the inability to recognize docker inside the docker extension is the same. The docker extension doesn't reinstall itself as far as I can tell.

mark-turner commented 1 month ago

@danegsta I made that change to docker.dockerPath but it made no difference. As shown in the screenshot, the connection is somehow semi-broken, in that the extension thinks Docker is not installed, and yet the terminal window is actually logged in to the running Docker image.

Screenshot 2024-09-27 at 20 57 45

mark-turner commented 1 month ago

@SusanWhiteUTK my setup is nearly identical. I will update to Sonoma 14.7 over the weekend to see it makes any difference, however unlikely.

danegsta commented 1 month ago

@mark-turner when you connect VSCode to a Dev Container (whether its running locally or on another machine), your IDE and extensions are running in the context of the container itself rather than the host machine, so any Docker commands we're running are executing inside the Dev Container.

You can see this guide for specific details and guidance on the different Docker support modes in Dev Container.

SusanWhiteUTK commented 1 month ago

@danegsta - Wow, thank you for that. I confess I'm learning how to operate in docker, and adding vscode to this mix and also mac complicates things. I'll give a run, see how it goes, and report back.

mark-turner commented 1 month ago

@danegsta thank you, I will look at those docs. But I have to say I'm rather confused because this issue just popped up a week ago. Prior to that, it was working fine. Upon opening the project in VS Code, it would fire up Docker Desktop and everything just worked. Then suddenly it didn't.

danegsta commented 1 month ago

Accessing Docker from within a container is definitely not the most straightforward thing; the DevContainer features make it a bit more manageable. One other option that might work is to force the Docker extension to run in “local” mode in your DevContainer workspace. See this section of the docs for an example of how to force the Docker extension into local mode in your workspace.

mark-turner commented 1 month ago

@danegsta thanks for the pointer to adding the extension to devcontainer.json. I did that and rebuilt the container. The good news is that the extension icon now remains in the sidebar. But I still get the "Docker is not installed" message on launch, and the "Failed to connect" message when I select the extension.

Screenshot 2024-10-03 at 17 24 35

Screenshot 2024-10-03 at 17 25 22

Screenshot 2024-10-03 at 17 26 50

bwateratmsft commented 1 month ago

Doing a docker-in-docker setup like this is possible but it's really painful. I'd recommend just having a separate window open on the host where you manage containers.

AzCode-Bot commented 1 month ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!