devcontainers / features

A collection of Dev Container Features managed by Dev Container spec maintainers. See https://github.com/devcontainers/feature-starter to publish your own
https://containers.dev/features
MIT License
919 stars 371 forks source link

[desktop-lite] How to troubleshoot connection problems? #762

Open NicolasRouquette opened 11 months ago

NicolasRouquette commented 11 months ago

I had been using this feature successfully when my system was running Windows 10; though I had to use the wsl-vpnkit to deal with full-tunnel VPN problems.

Now, my system has been updated to Windows 11; I no longer need wsl-vpnkit; however, the desktop-lite feature no longer works.

Here's my environment:

WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.2715

Unfortunately, I cannot share the Docker image we use, it is based on Ubuntu 20.04 LTS.

I use the devcontainer CLI to build an image with all the features I need:

PLATFORMS="linux/amd64,linux/arm64"
DEVCONTAINER_IMAGE="artifactory-fn.jpl.nasa.gov:16001/gov/nasa/jpl/imce/autonomica/2dcruiser-devcontainer:2023.11.16"
devcontainer build \
    --no-cache \
    --workspace-folder . \
    --config devcontainer.json \
    --image-name $DEVCONTAINER_IMAGE \
    --platform $PLATFORMS \
    --push true 

where devcontainer.json is:

  "name": "noetic desktop-full mexec-ros",
  "dockerFile": "Dockerfile",
  "features": {
    "ghcr.io/devcontainers-contrib/features/pdm:2": {
      "version": "latest"
    },
    "ghcr.io/devcontainers/features/desktop-lite:1": {
      "version": "latest",
      "noVncVersion": "1.2.0",
      "password": "vscode",
      "webPort": "6080",
      "vncPort": "5901"
    },
    "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
      "packages": "firefox,emacs,libtool"
    }
  }
}

The first indication of trouble happens when I start the devcontainer:

[77 ms] Dev Containers 0.321.0 in VS Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e).
[76 ms] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser
[610 ms] Start: Resolving Remote
[618 ms] Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser
[1118 ms] Start: Run: wsl -d Ubuntu-20.04 -e /bin/sh -c cd '/opt/local/autonomica/2dcruiser' && /bin/sh
[1127 ms] Start: Run in host: id -un
[1469 ms] nfr
[1471 ms] 
[1471 ms] Start: Run in host:  (command -v getent >/dev/null 2>&1 && getent passwd 'nfr' || grep -E '^nfr|^[^:]*:[^:]*:nfr:' /etc/passwd || true)
[1474 ms] Start: Run in host: echo ~
[1475 ms] /home/nfr
[1475 ms] 
[1476 ms] Start: Run in host: test -x '/home/nfr/.vscode-remote-containers/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/node'
[1476 ms] 
[1477 ms] 
[1477 ms] Exit code 1
[1477 ms] Start: Run in host: test -x '/home/nfr/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/node'
[1478 ms] 
[1478 ms] 
[1478 ms] Start: Run in host: test -f '/home/nfr/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/node_modules/node-pty/package.json'
[1479 ms] 
[1479 ms] 
[1479 ms] Start: Run in host: test -f '/home/nfr/.vscode-remote-containers/dist/vscode-remote-containers-server-0.321.0.js'
[1480 ms] 
[1480 ms] 
[1483 ms] userEnvProbe: loginInteractiveShell (default)
[1483 ms] userEnvProbe: not found in cache
[1483 ms] userEnvProbe shell: /bin/zsh
[2523 ms] userEnvProbe PATHs:
Probe:     '/home/nfr/.sdkman/candidates/java/current/bin:/home/nfr/.sdkman/candidates/gradle/current/bin:/opt/ros/noetic/bin:/snap/bin:/home/nfr/.krew/bin:/home/nfr/.elan/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0/:/mnt/c/windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/Enterprise Vault/EVClient/x64/:/mnt/c/Program Files (x86)/HID Global/ActivClient/:/mnt/c/Program Files/HID Global/ActivClient/:/mnt/c/Program Files (x86)/Pulse Secure/VC142.CRT/X64/:/mnt/c/Program Files (x86)/Pulse Secure/VC142.CRT/X86/:/mnt/c/Program Files (x86)/Common Files/Pulse Secure/TNC Client Plugin/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files (x86)/GnuPG/bin:/mnt/c/Program Files/MATLAB/R2023a/runtime/win64:/mnt/c/Program Files/MATLAB/R2023a/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/Docker/host/bin:/mnt/c/Users/nfr/scoop/apps/nodejs/current/bin:/mnt/c/Users/nfr/scoop/apps/nodejs/current:/mnt/c/Users/nfr/go/bin:/mnt/c/Users/nfr/scoop/apps/python/current/Scripts:/mnt/c/Users/nfr/scoop/apps/python/current:/mnt/c/Users/nfr/scoop/apps/maven/current/bin:/mnt/c/Users/nfr/scoop/apps/nvm/current/nodejs/nodejs:/mnt/c/Users/nfr/scoop/apps/miniconda3/current/scripts:/mnt/c/Users/nfr/scoop/apps/miniconda3/current/Library/bin:/mnt/c/Program Files/MySQL/MySQL Shell 8.0/bin/:/mnt/c/Users/nfr/scoop/apps/pyenv/current/pyenv-win/bin:/mnt/c/Users/nfr/scoop/apps/pyenv/current/pyenv-win/shims:/mnt/c/Users/nfr/.elan/bin:/mnt/c/Users/nfr/scoop/apps/openjdk17/current/bin:/mnt/c/Users/nfr/scoop/apps/yarn/current/global/node_modules/.bin:/mnt/c/Users/nfr/scoop/apps/yarn/current/bin:/mnt/c/Users/nfr/scoop/shims:/mnt/c/Users/nfr/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/nfr/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/nfr/AppData/Local/JetBrains/Toolbox/scripts:/mnt/c/opt/local/ghcup/bin:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/lib:/home/nfr/.antigen/bundles/Tarrasch/zsh-autoenv:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/scd:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/kubectl:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git-prompt:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git-extras:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git-auto-fetch:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/git-escape-magic:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/gpg-agent:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/microk8s:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/minikube:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/command-not-found:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/urltools:/home/nfr/.antigen/bundles/robbyrussell/oh-my-zsh/plugins/sbt:/home/nfr/.antigen/bundles/zsh-users/zsh-syntax-highlighting:/home/nfr/.local/bin'
Container: None
[2531 ms] Setting up container for folder or workspace: /opt/local/autonomica/2dcruiser
[2602 ms] Start: Check Docker is running
[2603 ms] Start: Run in Host: docker version --format {{.Server.APIVersion}}
[2701 ms] Server API version: 1.43
[2702 ms] Start: Run in Host: docker volume ls -q
[2797 ms] Start: Run in Host: docker inspect --type container c7a3f47938ee57331ac6db0eaf52b1fda52f5956294511c520903d2612d6f47b
[2895 ms] Start: Run in Host: docker ps -q -a --filter label=vsch.local.folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --filter label=vsch.quality=stable
[2986 ms] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --filter label=devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json
[3066 ms] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser
[3147 ms] Start: Run in Host: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser
[3239 ms] Start: Run in Host: /home/nfr/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.321.0/dist/spec-node/devContainersSpecCLI.js read-configuration --workspace-folder /opt/local/autonomica/2dcruiser --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --id-label devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json --log-level debug --log-format json --config /opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json --mount-workspace-git-root
[3436 ms] @devcontainers/cli 0.52.1. Node.js v18.15.0. linux 5.15.133.1-microsoft-standard-WSL2 x64.
[3436 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --filter label=devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json
[3627 ms] Start: Run in Host: /home/nfr/.vscode-server/bin/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/node /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.321.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-623e6b91-c659-43ee-9fe2-8f47c7505ed81700595721390 --workspace-folder /opt/local/autonomica/2dcruiser --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --id-label devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json --log-level debug --log-format json --config /opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --mount type=bind,source=/mnt/wslg/runtime-dir/wayland-0,target=/tmp/vscode-wayland-bfee12b0-0646-41f9-acf5-99261cbc5399.sock --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root
[3866 ms] @devcontainers/cli 0.52.1. Node.js v18.15.0. linux 5.15.133.1-microsoft-standard-WSL2 x64.
[3866 ms] Start: Run: docker buildx version
[4013 ms] github.com/docker/buildx v0.11.2-desktop.5 f20ec1393426619870066baba9618cf999063886
[4013 ms] 
[4013 ms] Start: Resolving Remote
[4230 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --filter label=devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json
[4324 ms] Start: Run: docker inspect --type image artifactory-fn.jpl.nasa.gov:16001/gov/nasa/jpl/imce/autonomica/2dcruiser-devcontainer:2023.11.16
[4616 ms] Start: Run: docker-credential-desktop.exe get
[9001 ms] local container features stored at: /home/nfr/.vscode-remote-containers/dist/dev-containers-cli-0.321.0/dist/node_modules/vscode-dev-containers/container-features
[9002 ms] Start: Run: tar --no-same-owner -x -f -
[9025 ms] Start: Run: docker build -f /tmp/devcontainercli-nfr/updateUID.Dockerfile-0.52.1 -t vsc-2dcruiser-cfa5575e629d01ccf2491747782d4f50ff6667892d172eac54ffbcd3840b4abc-uid --build-arg BASE_IMAGE=artifactory-fn.jpl.nasa.gov:16001/gov/nasa/jpl/imce/autonomica/2dcruiser-devcontainer:2023.11.16 --build-arg REMOTE_USER=vscode --build-arg NEW_UID=1000 --build-arg NEW_GID=1000 --build-arg IMAGE_USER=vscode /tmp/devcontainercli-nfr/empty-folder
[+] Building 2.1s (6/6) FINISHED                                 docker:default
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => [internal] load build definition from updateUID.Dockerfile-0.52.1      0.0s
 => => transferring dockerfile: 1.36kB                                     0.0s
 => [internal] load metadata for artifactory-fn.jpl.nasa.gov:16001/gov/na  2.0s
 => [1/2] FROM artifactory-fn.jpl.nasa.gov:16001/gov/nasa/jpl/imce/autono  0.0s
 => CACHED [2/2] RUN eval $(sed -n "s/vscode:[^:]*:\([^:]*\):\([^:]*\):[^  0.0s
 => exporting to image                                                     0.0s
 => => exporting layers                                                    0.0s
 => => writing image sha256:5901f3ea0ae8bc1db5c0cbfb24a94d3db819da2a70959  0.0s
 => => naming to docker.io/library/vsc-2dcruiser-cfa5575e629d01ccf2491747  0.0s

What's Next?
  View a summary of image vulnerabilities and recommendations → docker scout quickview
[11799 ms] Start: Run: docker -v
[11864 ms] Start: Run: docker events --format {{json .}} --filter event=start
[11872 ms] Start: Starting container
[11872 ms] Start: Run: docker run --sig-proxy=false -a STDOUT -a STDERR --mount source=/opt/local/autonomica/2dcruiser,target=/2dcruiser,type=bind --mount type=volume,src=vscode,dst=/vscode --mount type=bind,src=/mnt/wslg/runtime-dir/wayland-0,dst=/tmp/vscode-wayland-bfee12b0-0646-41f9-acf5-99261cbc5399.sock -l devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser -l devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json -u vscode --shm-size=2g --privileged --network=host --init --entrypoint /bin/sh -l devcontainer.metadata=[{"id":"ghcr.io/devcontainers-contrib/features/pdm:2"},{"id":"ghcr.io/devcontainers/features/desktop-lite:1","init":true,"entrypoint":"/usr/local/share/desktop-init.sh"},{"id":"ghcr.io/rocker-org/devcontainer-features/apt-packages:1"},{"customizations":{"vscode":{"extensions":["ms-python.python","ms-python.vscode-pylance","ms-toolsai.jupyter","ms-toolsai.jupyter-keymap","ms-toolsai.jupyter-renderers","ms-toolsai.vscode-jupyter-powertoys","ms-vscode-remote.remote-ssh-edit","donjayamanne.python-extension-pack","ms-vscode-remote.vscode-remote-extensionpack","ms-iot.vscode-ros"]}},"mounts":[],"containerUser":"vscode","remoteUser":"vscode","portsAttributes":{"5901":{"label":"vnc"},"6080":{"label":"desktop"}},"forwardPorts":[6080,5901]}] vsc-2dcruiser-cfa5575e629d01ccf2491747782d4f50ff6667892d172eac54ffbcd3840b4abc-uid -c echo Container started
Container started
[12141 ms] Start: Run: docker ps -q -a --filter label=devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\opt\local\autonomica\2dcruiser --filter label=devcontainer.config_file=/opt/local/autonomica/2dcruiser/.devcontainer/devcontainer.json
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
[12272 ms] Start: Run: docker inspect --type container cd6545555506
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
sudo: unable to resolve host MT-313357: No address associated with hostname
[12401 ms] Start: Inspecting container
[12402 ms] Start: Run: docker inspect --type container cd6545555506c227d5a81b52f93578d86bfdbc413ff706ea3cdb143dc4500ecd
[12496 ms] Start: Run in container: /bin/sh
[12509 ms] Start: Run in container: uname -m
[12641 ms] x86_64
[12641 ms] 
[12641 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[12644 ms] NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
[12644 ms] 

In the above, the errors: sudo: unable to resolve host MT-313357: No address associated with hostname are due to a missing entry in /etc/hosts, which is this:

127.0.0.1       localhost
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

To fix this issue, I run this script:

echo "127.0.0.1 $(cat /etc/hostname)" | sudo tee -a /etc/hosts

After that, I check that noVNC is running:

cat /tmp/noVNC.log 
[Tue Nov 21 19:42:15 UTC 2023] Process started.
Warning: could not find self.pem
Using local websockify at /usr/local/novnc/noVNC-1.2.0/utils/websockify/run
Starting webserver and WebSockets proxy on port 6080
WebSocket server settings:
  - Listen on :6080
  - Web server. Web root: /usr/local/novnc/noVNC-1.2.0
  - No SSL/TLS support (no cert file)
  - proxying from :6080 to localhost:5901

Navigate to this URL:

    http://MT-313357:6080/vnc.html?host=MT-313357&port=6080

Press Ctrl-C to exit

and that XtigerVNC is running too:

cat /tmp/Xtigervnc.log 

** Tue Nov 21 19:42:14 UTC 2023 **
[Tue Nov 21 19:42:14 UTC 2023] Process started.
hostname: No address associated with hostname
/usr/bin/xauth:  file /home/vscode/.Xauthority does not exist

New ':1 (vscode)' desktop at :1 on machine 

Starting applications specified in /etc/X11/Xvnc-session
Log file is /home/vscode/.vnc/:1.log

Use xtigervncviewer -SecurityTypes VncAuth -passwd /usr/local/etc/vscode-dev-containers/vnc-passwd :1 to connect to the VNC server.

and that the VNC server is running too:

cat ~/.vnc/\:1.log 

Xvnc TigerVNC 1.10.0 - built Apr  9 2020 06:49:31
Copyright (C) 1999-2019 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12008000, The X.Org Foundation

Tue Nov 21 19:42:14 2023
 vncext:      VNC extension running!
 vncext:      Listening for VNC connections on local interface(s), port 5901
 vncext:      created VNC server for screen 0

In VSCode, I see that the ports are associated to running processes:

image

So, everything looks good; except that I still cannot connect.

http://localhost:6080/vnc.html?password=vscode&autoconnect=true&resize=remote

gives me an error: Failed to connect.

With RealVNC Viewer, I try to connect at localhost:5901, and I get 'Timed out waiting for a response from the computer'

I don't see any errors in the container logs mentioned above.

Interestingly, in the container, I can execute a command like this: DISPLAY=:0 xterm & and the xterm window shows up in Windows thanks to WSLg.

Can someone help me understand what is going on and how do I make this work again?

samruddhikhandale commented 11 months ago

Hello 👋

Thank you for opening such a detailed information!

Let's try to narrow down the issue, @NicolasRouquette can you try if this simple configuration 👇 works for you? This way we can verify if the issue is with desktop-lite Feature of whether other elements of your dev config are interfering/conflicting. It will help us investigate the issue in an easy manner, thanks!

{
    "image": "mcr.microsoft.com/devcontainers/base:focal", // works with WSL or use `ubuntu:20.4` 
    "features": {
        "ghcr.io/devcontainers/features/desktop-lite": {
            "password": "vscode",
            "webPort": "6080"
        }
    },
    "forwardPorts": [
        6080
    ],
    "portsAttributes": {
        "6080": {
            "label": "Web VNC"
        }
    }
}
NicolasRouquette commented 11 months ago

Thanks for the suggestion; it makes sense to focus on the desktop-lite feature with nothing else. I managed to replicate the problem in a simple example here: https://github.com/NicolasRouquette/vscode-devc-ubuntu-desktop

NicolasRouquette commented 11 months ago

@samruddhikhandale Have you been able to reproduce the problem with my example? https://github.com/NicolasRouquette/vscode-devc-ubuntu-desktop