flathub / com.visualstudio.code

https://flathub.org/apps/details/com.visualstudio.code
152 stars 72 forks source link

Unable to use the docker extension #55

Open fesm0750 opened 6 years ago

fesm0750 commented 6 years ago

I've tried to use the docker extension but I got the following error:

Unable to connect to Docker, is the Docker daemon running?

Usually this error is fixed by adding the user to the docker group. However this fix does not seem to work in the flatpak version of vscode.

stobbsm commented 5 years ago

The docker socket isn't available to the flatpak sandbox. You can probably create an override for it if you really want.

Take a look here: https://www.systutorials.com/docs/linux/man/1-flatpak-override/

erindru commented 5 years ago

I got it working by running:

sudo flatpak override --system --filesystem=/run/docker.sock com.visualstudio.code

However, I cannot get the Remote Development extension for Containers to work because it requires the Docker CLI - and I cannot figure out how to make the Docker CLI available within the sandbox

thisboyiscrazy commented 4 years ago

@erindru How did you get this to work, I got the file override to work but but the permissions are wrong?

erindru commented 4 years ago

I can't remember (October was a long time ago) - it just worked. Possibly because my user is a member of the 'docker' group so that I can use the Docker CLI without prefixing everything with sudo.

thisboyiscrazy commented 4 years ago

My user is also a member of the docker group but when it gets mapped in /run/docker.sock is owner by nfsnobody

srw-rw----  1 nfsnobody nfsnobody   0 Jan  8 14:45 docker.sock

Did you find any other work around this would be nice to have.

pio2398 commented 4 years ago

I created file docker.sh with that:

#!/bin/sh
flatpak-spawn --host docker "$@"

And set path to it in config. it has many disadvantages but Remote Development extension for Containers works. This maybe long term better solution: https://github.com/containers/podman/issues/4131. Running podman in docker should be similar to running podman in flatpak sandbox.

ljrk0 commented 3 years ago

Maybe one could ship podman-cli in the flatpak, AFAIK the service files and all the rest don't need to be installed, "just the binary", together with exposing the socket:

flatpak override --user --filesystem=xdg-run/podman com.visualstudio.code

This provides access to the unprivileged podman containers via the socket API and the binary would only need to connect to the socket.

FilBot3 commented 3 years ago

Maybe one could ship podman-cli in the flatpak, AFAIK the service files and all the rest don't need to be installed, "just the binary", together with exposing the socket:

flatpak override --user --filesystem=xdg-run/podman com.visualstudio.code

This provides access to the unprivileged podman containers via the socket API and the binary would only need to connect to the socket.

This suggestion did get me going in a direction, and I have some error output! I was able to interact with the Podman instance on the Flatpak Host after enabling the Podman socket, but VSCode did seem to have some issues itself.

I hope this helps someone else. I think the Podman-Remote idea is the way to go in this instance.

FilBot3 commented 3 years ago

Using VSCode Flatpak to launch Podman-Remote containers for DevContainers

Overview

References

Setup

Install Visual Studio Code

Install Visual Studio Code and a Podman tool

➜  ~ flatpak search com.visualstudio.code
Name                                       Description                                               Application ID                                 Version                        Branch              Remotes
Visual Studio Code                         Visual Studio Code. Code editing. Redefined.              com.visualstudio.code                          1.57.1-1623936438              stable              flathub-root,flathub
Visual Studio Code (Insiders)              Visual Studio Code. Code editing. Redefined.              com.visualstudio.code.insiders                 1.61.0-1630915382              beta                flathub-beta
Code - OSS                                 Visual Studio Code. Code editing. Redefined.              com.visualstudio.code-oss                      1.47.2                         beta                flathub-beta
Podman                                     A tool for managing OCI containers and pods               com.visualstudio.code.tool.podman              3.3.1                          20.08               flathub-root,flathub
fish                                       The user-friendly command line shell                      com.visualstudio.code.tool.fish                3.3.1                          20.08               flathub-root,flathub
Code - OSS                                 Visual Studio Code. Code editing. Redefined.              com.visualstudio.code-oss                      1.60.0                         stable              flathub-root,flathub
➜  ~ flatpak --user install flathub com.visualstudio.code com.visualstudio.code.tool.podman

Override Flatpak to allow Podman Socket

See the GitHub issue for vscode flatpak issue 55.

flatpak override --user --filesystem=xdg-run/podman com.visualstudio.code

Enable Podman Socket for the User

systemctl --user enable --now podman.socket

Setup Visual Studio Code to use Podman-Remote

Install the following plugins.

flatpak run --command=bash com.visualstudio.code
code --install-extension ms-vscode-remote.vscode-remote-extensionpack

This installs the Remote Development VSCode Plugin pack to enable Container development. Now, press CTRL+SHIF+P and open Settings (UI). Search for docker and replace the docker executable word with podman-remote.

Test if podman-remote works

This was a little confusing at first, for some reason, I thought it would just use podman but it provides podman-remote.

  1. Open Visual Studio Code (Flatpak).
  2. Press CTRL+(backtick) to launch terminal.
  3. Type the following
podman-remote container ls

This should show the list of Container Images, if any.

Create the DevContainer enabled project

.devcontainer/devcontainer.json

{
    "image": "docker.io/library/golang:1.16"
}

Launch code in the project with devcontainer

Inside of VSCode, open a folder. Then when prompted, Reopen folder in DevContainer.

The errors listed below should be what appear. The subsequent times I tried opening this, I could not get the logs to show. Probably has soemthing to do with a cached image, or volume.

```bash [139 ms] Remote-Containers 0.183.0 in VS Code 1.57.1 (507ce72a4466fbb27b715c3722558bb15afa9f48). [138 ms] Start: Resolving Remote [144 ms] Setting up container for folder or workspace: /var/home/dudleyp/Documents/Development/Golang/vscode_devcontainer_example [155 ms] Start: Check Docker is running [155 ms] Start: Run: podman-remote version --format {{.Server.APIVersion}} [241 ms] Server API version: 3.1.0 [255 ms] Start: Run: git rev-parse --show-cdup [266 ms] Start: Run: podman-remote ps -q -a --filter label=vsch.local.folder=/var/home/dudleyp/Documents/Development/Golang/vscode_devcontainer_example --filter label=vsch.quality=stable [300 ms] Start: Run: podman-remote inspect --type image docker.io/library/golang:1.16 [351 ms] Start: Run: podman-remote -v [383 ms] Start: Run: podman-remote events --format json --filter event=start [390 ms] Start: Starting container [390 ms] Start: Run: podman-remote run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/var/home/dudleyp/Documents/Development/Golang/vscode_devcontainer_example,target=/workspaces/vscode_devcontainer_example --mount type=volume,src=vscode,dst=/vscode -l vsch.local.folder=/var/home/dudleyp/Documents/Development/Golang/vscode_devcontainer_example -l vsch.quality=stable -l vsch.remote.devPort=0 --entrypoint /bin/sh docker.io/library/golang:1.16 -c echo Container started ; trap "exit 0" 15; while sleep 1 & wait $!; do :; done Trying to pull docker.io/library/golang:1.16... Getting image source signatures Copying blob sha256:be91c38d26fffbfafc3f2df63d098e225eb62b951d509a002d1ab6b1f245ffb8 Copying blob sha256:2756ef5f69a5190f4308619e0f446d95f5515eef4a814dbad0bcebbbbc7b25a8 Copying blob sha256:27b0a22ee906271a6ce9ddd1754fdd7d3b59078e0b57b6cc054c7ed7ac301587 Copying blob sha256:8c9b225c5e05003a6c5b3d83a1ecb00b2ac55d2ef9d404065039a4f99a5da1c6 Copying blob sha256:955615a668ce169f8a1443fc6b6e6215f43fe0babfb4790712a2d3171f34d366 Copying blob sha256:4e94c8ba5874feacb79d2235c4b275408a5110a5c12fd4c45200199ad8847091 Copying blob sha256:911ea9f2bd51e53a455297e0631e18a72a86d7e2c8e1807176e80f991bde5d64 Copying config sha256:4f66698aec33de68b52df801d79cbf5d707b1f8d2c633734ea88860688bcafa4 Writing manifest to image destination Storing signatures Container started [2246 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [2294 ms] Start: Run: podman-remote ps -q -a --filter label=vsch.local.folder=/var/home/dudleyp/Documents/Development/Golang/vscode_devcontainer_example --filter label=vsch.quality=stable [2327 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1 [2366 ms] Start: Inspecting container [2366 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [2413 ms] Start: Run in container: /bin/sh [2421 ms] Start: Run in container: uname -m [2519 ms] x86_64 [2521 ms] [2521 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null [2528 ms] PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" [2531 ms] [2531 ms] Start: Run in container: cat /etc/passwd [2545 ms] Start: Updating configuration state [2846 ms] Start: Setup shutdown monitor [2848 ms] Forking shutdown monitor: /var/home/dudleyp/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.183.0/dist/shutdown/shutdownMonitorProcess /run/user/1000/vscode-remote-containers-c6ae858b7fb5822a0913108047df95849a009728.sock singleContainer Debug /var/home/dudleyp/.var/app/com.visualstudio.code/config/Code/logs/20210906T161131/exthost1/ms-vscode-remote.remote-containers 1630962760546 [2854 ms] Start: Run in container: test -d /root/.vscode-server [2857 ms] [2857 ms] [2857 ms] Exit code 1 [2858 ms] Start: Run in container: test -d /root/.vscode-remote [2864 ms] [2864 ms] [2865 ms] Exit code 1 [2866 ms] Start: Run in container: test -f /var/vscode-server/.patchEtcEnvironmentMarker [2869 ms] [2869 ms] [2869 ms] Exit code 1 [2870 ms] Start: Run in container: set -o noclobber ; mkdir -p '/var/vscode-server' && { > '/var/vscode-server/.patchEtcEnvironmentMarker' ; } 2> /dev/null [2896 ms] [2897 ms] [2897 ms] Start: Run in container: cat >> /etc/environment <<'etcEnvrionmentEOF' [2902 ms] [2903 ms] [2903 ms] Start: Run in container: test -f /var/vscode-server/.patchEtcProfileMarker [2906 ms] [2906 ms] [2906 ms] Exit code 1 [2907 ms] Start: Run in container: set -o noclobber ; mkdir -p '/var/vscode-server' && { > '/var/vscode-server/.patchEtcProfileMarker' ; } 2> /dev/null [2920 ms] [2920 ms] [2921 ms] Start: Run in container: sed -i -E 's/((^|\s)PATH=)([^\$]*)$/\1${PATH:-\3}/g' /etc/profile || true [2935 ms] [2936 ms] [2937 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null [2943 ms] [2944 ms] [2944 ms] Start: Run in container: cat /root/.vscode-server/data/Machine/settings.json [2946 ms] [2946 ms] cat: /root/.vscode-server/data/Machine/settings.json: No such file or directory [2947 ms] Exit code 1 [2947 ms] Start: Run in container: test -d /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48 [2949 ms] [2949 ms] [2949 ms] Exit code 1 [2949 ms] Start: Run in container: test -d /vscode/vscode-server/bin/x64/507ce72a4466fbb27b715c3722558bb15afa9f48 [2951 ms] [2951 ms] [2951 ms] Exit code 1 [2951 ms] Installing VS Code Server for commit 507ce72a4466fbb27b715c3722558bb15afa9f48 [2952 ms] Start: Downloading VS Code Server [2952 ms] 507ce72a4466fbb27b715c3722558bb15afa9f48 x64 stable [6544 ms] Start: Installing VS Code Server [6544 ms] Start: Run in container: mkdir -p /vscode/vscode-server/bin/x64/507ce72a4466fbb27b715c3722558bb15afa9f48_1630962767090 [6550 ms] [6550 ms] [6636 ms] Start: Run in container: (dd iflag=fullblock bs=8192 count=5569 2>/dev/null; dd iflag=fullblock bs=4277 count=1 2>/dev/null) | tar --no-same-owner -xz --strip-components 1 -C /vscode/vscode-server/bin/x64/507ce72a4466fbb27b715c3722558bb15afa9f48_1630962767090 [8539 ms] [8539 ms] [8540 ms] Start: Run in container: mv -n /vscode/vscode-server/bin/x64/507ce72a4466fbb27b715c3722558bb15afa9f48_1630962767090 /vscode/vscode-server/bin/x64/507ce72a4466fbb27b715c3722558bb15afa9f48 [8545 ms] [8545 ms] [8546 ms] Start: Run in container: mkdir -p '/root/.vscode-server/bin' && ln -s '/vscode/vscode-server/bin/x64/507ce72a4466fbb27b715c3722558bb15afa9f48' '/root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48' [8552 ms] [8554 ms] [8555 ms] Start: Run in container: cd '/vscode/vscode-server/bin/x64' && ls -t | tail -n +10 | xargs rm -rf [8555 ms] Start: Launching Remote-Containers helper. [8557 ms] Start: Run: gpgconf --list-dir agent-extra-socket [8572 ms] [8573 ms] [8580 ms] /run/user/1000/gnupg/S.gpg-agent.extra [8583 ms] [8584 ms] Start: Run in container: gpgconf --list-dir agent-socket [8595 ms] /root/.gnupg/S.gpg-agent [8597 ms] [8599 ms] Start: Run in container: gpgconf --list-dir homedir [8605 ms] /root/.gnupg [8606 ms] [8606 ms] Start: Run in container: ls '/root/.gnupg/private-keys-v1.d' 2>/dev/null [8610 ms] [8611 ms] [8611 ms] Exit code 2 [8612 ms] Start: Run in container: mkdir -p -m 700 '/root/.gnupg' [8615 ms] userEnvProbe: loginInteractiveShell (default) [8616 ms] userEnvProbe shell: /bin/bash [8619 ms] [8620 ms] [8620 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --system credential.helper '!f() { /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node /tmp/vscode-remote-containers-50d5f6c32d3766449088221e957f79e5de354e37.js $*; }; f' || true [8621 ms] Start: Run: gpgconf --list-dir homedir [8633 ms] /var/home/dudleyp/.gnupg [8634 ms] [8637 ms] [8637 ms] [8638 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-50d5f6c32d3766449088221e957f79e5de354e37.js' >/tmp/vscode-remote-containers-50d5f6c32d3766449088221e957f79e5de354e37.js [8638 ms] Start: Preparing Extensions [8641 ms] [8641 ms] [8646 ms] Start: Run in container: gpgconf --list-dir homedir [8651 ms] /root/.gnupg [8651 ms] [8651 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.installExtensionsMarker' ; } 2> /dev/null [8652 ms] Start: Run: gpg-connect-agent updatestartuptty /bye [8664 ms] [8664 ms] [8666 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-server-50d5f6c32d3766449088221e957f79e5de354e37.js' >/tmp/vscode-remote-containers-server-50d5f6c32d3766449088221e957f79e5de354e37.js [8673 ms] Extensions cache, install extensions: None [8675 ms] [8675 ms] [8676 ms] Start: Run in container: test -d /root/.vscode-server/extensionsCache && ls /root/.vscode-server/extensionsCache || true [8677 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node /tmp/vscode-remote-containers-server-50d5f6c32d3766449088221e957f79e5de354e37.js [8694 ms] [8694 ms] [8695 ms] Start: Run in container: test -d /vscode/vscode-server/extensionsCache && ls /vscode/vscode-server/extensionsCache || true [8701 ms] [8718 ms] [8720 ms] Extensions cache, link in container: None [8722 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink /proc/$pid/cwd ; readlink /proc/$pid/ns/mnt ; cat /proc/$pid/stat | tr " [8803 ms] Start: Starting VS Code Server [8804 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/server.sh --log debug --force-disable-user-env --use-host-proxy --port 0 --extensions-download-dir /root/.vscode-server/extensionsCache --start-server [9138 ms] * * Visual Studio Code Server * * Reminder: You may only use this software with Visual Studio family products, * as described in the license https://aka.ms/vscode-remote/license * Extension host agent listening on 34359 [9138 ms] Start: Run in container: echo 34359 >/root/.vscode-server/data/Machine/.devport [9140 ms] [9140 ms] [9141 ms] Port forwarding for container port 34359 starts listening on local port. [9142 ms] Port forwarding local port 34359 to container port 34359 [9151 ms] userEnvProbe PATHs: Probe: '/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' Container: '/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' [9189 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.onCreateCommandMarker' ; } 2> /dev/null [9200 ms] [9201 ms] [9201 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.updateContentCommandMarker' ; } 2> /dev/null [9206 ms] [9206 ms] [9207 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.postCreateCommandMarker' ; } 2> /dev/null [9217 ms] [9218 ms] [9222 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global credential.helper '!f() { /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node /tmp/vscode-remote-containers-50d5f6c32d3766449088221e957f79e5de354e37.js $*; }; f' || true [9242 ms] [9243 ms] [9244 ms] Start: Run in container: mkdir -p '/root/.vscode-server/data/Machine' && [ "$(cat '/root/.vscode-server/data/Machine/.postStartCommandMarker' 2>/dev/null)" != '2021-09-06T16:12:42.701489557-05:00' ] && echo '2021-09-06T16:12:42.701489557-05:00' > '/root/.vscode-server/data/Machine/.postStartCommandMarker' [9251 ms] [9252 ms] [9309 ms] Port forwarding connection from 39794 > 34359 > 34359 in the container. [9310 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [9444 ms] [21:12:49] Extension host agent started. [9650 ms] Port forwarding connection from 39810 > 34359 > 34359 in the container. [9651 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [10066 ms] [21:12:50] [::ffff:127.0.0.1][75fb6547][ManagementConnection] New connection established. [10077 ms] [21:12:50] [::ffff:127.0.0.1][8335c2a4][ExtensionHostConnection] New connection established. [10085 ms] [21:12:50] [::ffff:127.0.0.1][8335c2a4][ExtensionHostConnection] <187> Launched Extension Host Process. [10985 ms] Port forwarding 39794 > 34359 > 34359: Local close [10990 ms] Port forwarding 39794 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [10995 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [11110 ms] Port forwarding connection from 39818 > 34359 > 34359 in the container. [11111 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [11494 ms] [21:12:52] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [12651 ms] Port forwarding 39818 > 34359 > 34359: Local close [12656 ms] Port forwarding 39818 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [12663 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [12755 ms] Port forwarding connection from 39822 > 34359 > 34359 in the container. [12756 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [13346 ms] [21:12:53] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [14631 ms] Port forwarding 39822 > 34359 > 34359: Local close [14634 ms] Port forwarding 39822 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [14635 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [14748 ms] Port forwarding connection from 39828 > 34359 > 34359 in the container. [14749 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [15280 ms] [21:12:55] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [19631 ms] Port forwarding 39828 > 34359 > 34359: Local close [19635 ms] Port forwarding 39828 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [19636 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [19745 ms] Port forwarding connection from 39832 > 34359 > 34359 in the container. [19746 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [20233 ms] [21:13:00] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [24633 ms] Port forwarding 39832 > 34359 > 34359: Local close [24636 ms] Port forwarding 39832 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [24657 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [24752 ms] Port forwarding connection from 39846 > 34359 > 34359 in the container. [24754 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [25193 ms] [21:13:05] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [29633 ms] Port forwarding 39846 > 34359 > 34359: Local close [29638 ms] Port forwarding 39846 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [29643 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [29727 ms] Port forwarding connection from 39850 > 34359 > 34359 in the container. [29727 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [30206 ms] [21:13:10] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [34633 ms] Port forwarding 39850 > 34359 > 34359: Local close [34637 ms] Port forwarding 39850 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [34643 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [34722 ms] Port forwarding connection from 39854 > 34359 > 34359 in the container. [34723 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [35233 ms] [21:13:15] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [39634 ms] Port forwarding 39854 > 34359 > 34359: Local close [39637 ms] Port forwarding 39854 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [39644 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [39748 ms] Port forwarding connection from 39860 > 34359 > 34359 in the container. [39748 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [40193 ms] [21:13:20] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [44635 ms] Port forwarding 39860 > 34359 > 34359: Local close [44638 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [44643 ms] Port forwarding 39860 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [44722 ms] Port forwarding connection from 39864 > 34359 > 34359 in the container. [44722 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [45170 ms] [21:13:25] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [49634 ms] Port forwarding 39864 > 34359 > 34359: Local close [49637 ms] Port forwarding 39864 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [49639 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [49716 ms] Port forwarding connection from 39868 > 34359 > 34359 in the container. [49717 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [50097 ms] [21:13:30] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [54635 ms] Port forwarding 39868 > 34359 > 34359: Local close [54638 ms] Port forwarding 39868 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [54640 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [54714 ms] Port forwarding connection from 39872 > 34359 > 34359 in the container. [54715 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [55196 ms] [21:13:35] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [59636 ms] Port forwarding 39872 > 34359 > 34359: Local close [59639 ms] Port forwarding 39872 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [59641 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [59719 ms] Port forwarding connection from 39878 > 34359 > 34359 in the container. [59720 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [60197 ms] [21:13:40] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [64635 ms] Port forwarding 39878 > 34359 > 34359: Local close [64638 ms] Port forwarding 39878 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [64640 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [64712 ms] Port forwarding connection from 39882 > 34359 > 34359 in the container. [64713 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [65158 ms] [21:13:45] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [69637 ms] Port forwarding 39882 > 34359 > 34359: Local close [69640 ms] Port forwarding 39882 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [69644 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [69704 ms] Port forwarding connection from 39886 > 34359 > 34359 in the container. [69704 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [70256 ms] [21:13:50] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. [74636 ms] Port forwarding 39886 > 34359 > 34359: Local close [74639 ms] Port forwarding 39886 > 34359 > 34359 terminated by extension with code null and signal SIGKILL. [74640 ms] Start: Run: podman-remote inspect --type container 9d80bd8250d1797e2cb2840ece2129d71a3decd9cb726e034cf7379c5d586c08 [74713 ms] Port forwarding connection from 39894 > 34359 > 34359 in the container. [74715 ms] Start: Run in container: /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48/node -e [74950 ms] [21:13:55] [::ffff:127.0.0.1][75fb6547][ManagementConnection] The client has reconnected. ```
FilBot3 commented 3 years ago

There does seem to be this related project that does provide some tools.

I think it does need a readme as to what the project is attempting to do and provide. That way others can know how to use it immediately.

FilBot3 commented 3 years ago

Could this be something then with the allowed ports, or something blocking VSCode from connecting to the container on the host?

The Flatpak permissions for a default install.

➜  ~ flatpak info com.visualstudio.code

Visual Studio Code - Visual Studio Code. Code editing. Redefined.

          ID: com.visualstudio.code
         Ref: app/com.visualstudio.code/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 1.57.1-1623936438
     License: LicenseRef-proprietary=https://code.visualstudio.com/license
      Origin: flathub-user
  Collection: org.flathub.Stable
Installation: user
   Installed: 2.3 MB
     Runtime: org.freedesktop.Sdk/x86_64/20.08
         Sdk: org.freedesktop.Sdk/x86_64/20.08

      Commit: 66f03a7af14b49e5cc1dfb6daccb7cd67131404e273ae9d9ba61a91940483d14
      Parent: 65657b3d372b861e5e2bec202769287e44f7be6f405a0984109666e5e3a34189
     Subject: add support for mimetype x-scheme-handler/vscode (520cb933)
        Date: 2021-07-19 05:00:57 +0000
➜  ~ flatpak info --show-permissions com.visualstudio.code
[Context]
shared=network;ipc;
sockets=x11;pulseaudio;ssh-auth;
devices=all;
features=devel;
filesystems=xdg-config/kdeglobals:ro;host;

[Session Bus Policy]
org.freedesktop.Flatpak=talk
org.freedesktop.Notifications=talk
com.canonical.AppMenu.Registrar=talk
com.canonical.AppMenu.Registrar.*=talk
org.freedesktop.secrets=talk

[System Bus Policy]
org.freedesktop.login1=talk

[Environment]
LD_LIBRARY_PATH=/app/lib
NPM_CONFIG_GLOBALCONFIG=/app/etc/npmrc
FilBot3 commented 3 years ago

I also tried allowing --filesystem=/tmp to no avail.

Originally suggested here:

vteivans commented 2 years ago

Could this be solved by creating something like org.freedesktop.Sdk.Extension.docker?

FilBot3 commented 2 years ago

Could this be solved by creating something like org.freedesktop.Sdk.Extension.docker?

* that would add the `docker` and `docker-compose` executable in the sdk bin directory and to the path

* that would use the `docker.sock` from the parent system to interact with the docker from there

I think looking at something like podman-desktop Flatpak should help inform a decision on how to do this. Some how they are able to use Podman via a User Socket to access containers and such from within Flatpak.

mbnoimi commented 1 year ago

This bug still occurs. I unable to use docker from VSCode!

[Session Bus Policy] org.freedesktop.Flatpak=talk org.freedesktop.Notifications=talk com.canonical.AppMenu.Registrar=talk com.canonical.AppMenu.Registrar.*=talk org.freedesktop.secrets=talk

[System Bus Policy] org.freedesktop.login1=talk

[Environment] GTK_THEME=Mint-Y-Dark-Aqua LD_LIBRARY_PATH=/app/lib NPM_CONFIG_GLOBALCONFIG=/app/etc/npmrc ZYPAK_SPAWN_LATEST_ON_REEXEC=0 QT_STYLE_OVERRIDE=Adwaita-dark

deftdawg commented 1 year ago

Got this working! Here are the steps:

  1. First step is to get docker.sock inside the flatpak with this on the host:

    flatpak override --user --filesystem=/run/docker.sock com.visualstudio.code
  2. Next in VS Code Studio, open Preferences: Open User Settings (JSON) and make sure you have the following setting in your settings:

    {
    "docker.dockerPath": "/run/host/usr/bin/docker"
    }

After doing these two things (assuming docker ps works for you on your host), you should be able to refresh the containers and images list in the docker extension and use it normally within the VS Code Flatpak.

~NOTE: docker won't be found inside the VS Code Terminal unless you alias docker=/run/host/usr/bin/docker, if someone knows a way to get that to stick within a flatpak, please comment.~

UPDATE: seems the best way to do this is to accomplish this is to override the default shell with one that spawns via host-spawn. Save host-spawn to your home directory, rename it to remove the arch suffix, chmod +x to it. Then add this block to the User settings.json underneath the dockerPath config:

    "terminal.integrated.profiles.linux": {
        "bash": {
            "path": "${userHome}/host-spawn",
            "args": ["/bin/bash"],
            "overrideName": true
          }
    }
mbnoimi commented 1 year ago

Great, It works indeed. At last! after months. Thank you @deftdawg

lbssousa commented 1 year ago

I think looking at something like podman-desktop Flatpak should help inform a decision on how to do this. Some how they are able to use Podman via a User Socket to access containers and such from within Flatpak.

Looking at podman-desktop sources, I can see that it uses flatpak-spawn --host podman to interact with host system Podman.

A similar approach is used by project toolbox-vscode: it has (more specific: it generates) its own wrapper script to flatpak-spawn --host podman and passes it to Dev Container extension setting dev.containers.dockerPath. A more simple example of podman wrapper script is provided by distrobox documentation:

#!/bin/bash
set -x
if [ "$1" == "exec" ]; then
 # Remove 'exec' from $@
 shift
 script='
     result_command="podman exec"
        for i in $(printenv | grep "=" | grep -Ev " |\"" |
            grep -Ev "^(HOST|HOSTNAME|HOME|PATH|SHELL|USER|_)"); do

            result_command=$result_command --env="$i"
     done

        exec ${result_command} "$@"
    '
 exec flatpak-spawn --host sh -c "$script" - "$@"
else
 exec flatpak-spawn --host podman "$@"
fi

[UPDATE] After some testing, I've found that the flatpak-spawn --host podman approach works well for attaching to a running container (like one started by Toolbx or Distrobox), but not for devcontainers created by VSCode (if your project has a devcontainer.json file, for example). For these cases, the podman-remote approach seems to be the only one that works.

[UPDATE 2] There was a missing piece to make flatpak-spawn --host podman approach work with devcontainers. I need to run

flatpak override --filesystem=/tmp com.visualstudio.code

Now my setup works for both building devcontainers and attaching to running Toolbx/Distrobox containers.

s3rgeym commented 1 year ago

Got this working! Here are the steps:

  1. First step is to get docker.sock inside the flatpak with this on the host:
flatpak override --user --filesystem=/run/docker.sock com.visualstudio.code
  1. Next in VS Code Studio, open Preferences: Open User Settings (JSON) and make sure you have the following setting in your settings:
{
    "docker.dockerPath": "/run/host/usr/bin/docker"
}

After doing these two things (assuming docker ps works for you on your host), you should be able to refresh the containers and images list in the docker extension and use it normally within the VS Code Flatpak.

~NOTE: docker won't be found inside the VS Code Terminal unless you alias docker=/run/host/usr/bin/docker, if someone knows a way to get that to stick within a flatpak, please comment.~

UPDATE: seems the best way to do this is to accomplish this is to override the default shell with one that spawns via host-spawn. Save host-spawn to your home directory, rename it to remove the arch suffix, chmod +x to it. Then add this block to the User settings.json underneath the dockerPath config:

    "terminal.integrated.profiles.linux": {
        "bash": {
            "path": "${userHome}/host-spawn",
            "args": ["/bin/bash"],
            "overrideName": true
          }
    }
{
  "terminal.integrated.profiles.linux": {
    "host-zsh": {
      "path": "/usr/bin/flatpak-spawn",
      "args": [
        "--env=TERM=xterm-256color",
        "--host",
        "zsh"
      ]
    }
  },
  // ...
  "docker.dockerPath": "/run/host/usr/bin/docker",
  "dev.containers.dockerComposePath": "/run/host/usr/bin/docker-compose",
  "dev.containers.dockerPath": "/run/host/usr/bin/docker"
}
e93Ym0WnIO commented 1 year ago

I was able to see my docker containers and attach the shell from within Flatpak VSCode, but I wasn't able to "attach Visual Studio Code".

    "dev.containers.dockerComposePath": "/run/host/usr/bin/docker-compose",
    "dev.containers.dockerPath": "/run/host/usr/bin/docker"

Adding the above lines inside settings.json are now allowing me to attach the whole VSCode instance to the container.

AlbertoFabbri93 commented 1 year ago

@lbssousa

Now my setup works for both building devcontainers and attaching to running Toolbx/Distrobox containers.

Is this setup still working for you? I am on OpenSuse Aeon, I have tried everything but nothing seems to work. It is very frustrating...

fyang93 commented 1 year ago

The previous solutions are not working rn, on NixOS. We do need an official solution to this issue.

gremo commented 1 year ago

Not working for me, using docker desktop on Fedora 39. I think it may be related to using Docker Desktop and it's specific context.

When I open the project in Remote Container, I got a generic error. Log is inaccessibile. This is from the terminal:

[2086 ms] Dev Containers 0.321.0 in VS Code 1.84.1 (2b35e1e6d88f1ce073683991d1eff5284a32690f).
[2086 ms] Start: Run: /run/host/usr/bin/docker version --format {{.Server.APIVersion}}
[2107 ms] 1.43
[2275 ms] Start: Run: /app/extra/vscode/code --ms-enable-electron-run-as-node /home/gremo/.var/app/com.visualstudio.code/data/vscode/extensions/ms-vscode-remote.remote-containers-0.321.0/dist/spec-node/devContainersSpecCLI.js read-configuration --docker-path /run/host/usr/bin/docker --docker-compose-path /run/host/usr/bin/docker-compose --workspace-folder /home/gremo/Progetti/test-project --log-level debug --log-format json --config /home/gremo/Progetti/test-project/.devcontainer/devcontainer.json --include-merged-configuration --mount-workspace-git-root
[2410 ms] @devcontainers/cli 0.52.1. Node.js v18.15.0. linux 6.5.11-300.fc39.x86_64 x64.
[2410 ms] Start: Run: /run/host/usr/bin/docker ps -q -a --filter label=devcontainer.local_folder=/home/gremo/Progetti/test-project --filter label=devcontainer.config_file=/home/gremo/Progetti/test-project/.devcontainer/devcontainer.json
[2425 ms] Start: Run: /run/host/usr/bin/docker inspect --type container a1a2d9c86e4c
[2571 ms] Start: Run: /run/host/usr/bin/docker-compose version --short
[2576 ms] Start: Run: /run/host/usr/bin/docker compose version --short

VScode relevant settings:

  "dev.containers.dockerComposePath": "/run/host/usr/bin/docker-compose",
  "dev.containers.dockerPath": "/run/host/usr/bin/docker",

Docker context:

default             moby                Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                                            
desktop-linux *     moby                Docker Desktop                            unix:///home/gremo/.docker/desktop/docker.sock       
gremo commented 1 year ago

After some research I've found that my local docker commands works in a different way from the flatpak version one, I mean inside VSCode terminal.

Local:

gremo@desktop-fedora  ~  /usr/bin/docker compose version
Docker Compose version v2.23.0-desktop.1

VSCode terminal:

sh-5.1$ /run/host/usr/bin/docker compose version
docker: 'compose' is not a docker command.
See 'docker --help'

Since Docker now has the new syntax docker compose (and not the old one docker-compose), the Dev Containers extension wont' work. If you start a project in a Dev Container, you'll see:

[1825 ms] Start: Run: docker-compose version --short
[1830 ms] Start: Run: /run/host/usr/bin/docker compose version --short

The second line would of course fail.

Maybe there is some other folder to share/expose to Flatpak version, in order to make docker compose work.

archekb commented 10 months ago

@FilBot3 After last update of VSCode (flatpak) your solution is not works, for me, anymore. VSCode all the time shows

bash: podman-remote: command not found

the com.visualstudio.code (latest) and com.visualstudio.code.tool.podman (22.08) are installed.

Solution:

  1. Create path, which VSCode mount as default (for me node_modules/bin wasn't exist, then we create it):

    mkdir -p /home/${USER}/.var/app/com.visualstudio.code/data/node_modules/bin/
  2. Create script at /home/${USER}/.var/app/com.visualstudio.code/data/node_modules/bin/podman:

    #!/bin/sh
    flatpak-spawn --host podman "$@"
  3. Make it executable:

    chmod +x /home/${USER}/.var/app/com.visualstudio.code/data/node_modules/bin/podman
  4. Open VSCode settings and set dev.containers.dockerPath to podman

anubhavkini commented 10 months ago

@FilBot3 After last update of VSCode (flatpak) your solution is not works, for me, anymore. VSCode all the time shows

bash: podman-remote: command not found

the com.visualstudio.code (latest) and com.visualstudio.code.tool.podman (22.08) are installed.

This should be resolved when flathub/com.visualstudio.code.tool.podman#46 is merged.

iamWing commented 10 months ago

@FilBot3 After last update of VSCode (flatpak) your solution is not works, for me, anymore. VSCode all the time shows

bash: podman-remote: command not found

the com.visualstudio.code (latest) and com.visualstudio.code.tool.podman (22.08) are installed.

This should be resolved when flathub/com.visualstudio.code.tool.podman#46 is merged.

Having the same issue after the latest update. Looking at how to downgrade vscode to get it back to working for now.

RichardJECooke commented 10 months ago

Is there an easy way to fix please, like with Flatseal? There are so many comments here I'm not sure which to follow. I just want the dev containers extension to work.

RichardJECooke commented 10 months ago

I found a solution. Instead of having to use flatpak, you can run the following command to install a proper version of Visual Studio Code on a new machine all in the terminal without needing to use flatpak, like this:

curl -L -o vscode.deb "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64" &&
sudo dpkg -i vscode.deb &&
rm vscode.deb;
jbtrystram commented 10 months ago

FYI, If someone runs into this after updating the VSCode flatpak, makes sure to update the podman extension to the 23.08 branch as well :

flatpak remove com.visualstudio.code.tool.podman
flatpak install com.visualstudio.code.tool.podman

This setup now works again for me :)

jamescalderon commented 9 months ago

I was able to see my docker containers and attach the shell from within Flatpak VSCode, but I wasn't able to "attach Visual Studio Code".

    "dev.containers.dockerComposePath": "/run/host/usr/bin/docker-compose",
    "dev.containers.dockerPath": "/run/host/usr/bin/docker"

Adding the above lines inside settings.json are now allowing me to attach the whole VSCode instance to the container.

This worked for me as well.

rmiceli commented 8 months ago

FWIW on a Fedora host the docker.sock file is in a different location. I got this to work by running:

flatpak override --user --filesystem=/run/user/1000/docker.sock com.visualstudio.code

And updating the dev.containers.dockerComposePath and dev.containers.dockerPath settings as above.

adrian-herscu commented 6 months ago

In VSCode settings.json the tilda (~) is not recognized, had to enter the full path to the docker/podman wrapper script -- otherwise it logs that it cannot spawn...

adrian-herscu commented 6 months ago

Still it fails while trying to clone in volume...

[69 ms] Dev Containers 0.362.0 in VS Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685).
[68 ms] Start: Resolving Remote
[80 ms] Start: Check Docker is running
[81 ms] Start: Run: /var/home/adrianherscu/flatpak-podman version
[121 ms] Client:       Podman Engine
Version:      5.0.3
API Version:  5.0.3
Go Version:   go1.22.2
Built:        Fri May 10 03:00:00 2024
OS/Arch:      linux/amd64
[128 ms] Start: Run: /var/home/adrianherscu/flatpak-podman volume ls -q
[169 ms] Start: Run: /var/home/adrianherscu/flatpak-podman volume create --label vsch.local.repository=https://github.com/QA-Automation-Starter/basic-project.git/tree/main --label vsch.local.repository.unique=true --label vsch.local.repository.branch=main basic-project-main-c941e00e7797a402f987ab45c71885e3fa7b75f0cf84692f196746890cc2ebc7
[238 ms] Start: Run: /var/home/adrianherscu/flatpak-podman build -f /tmp/vsch-adrianherscu/bootstrap-image/0.362.0/bootstrap.Dockerfile -t vsc-volume-bootstrap /tmp/vsch-adrianherscu/bootstrap-image/0.362.0
Error: context must be a directory: "/tmp/vsch-adrianherscu/bootstrap-image/0.362.0"
[280 ms] Command failed: /var/home/adrianherscu/flatpak-podman build -f /tmp/vsch-adrianherscu/bootstrap-image/0.362.0/bootstrap.Dockerfile -t vsc-volume-bootstrap /tmp/vsch-adrianherscu/bootstrap-image/0.362.0
[280 ms] Exit code 125

Any suggestion?

adrian-herscu commented 6 months ago

Added /tmp to filesystems and solved previous issue... Now there is another one:

[1144 ms] Command failed: docker volume ls -q
[1145 ms] Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/volumes": dial unix /var/run/docker.sock: connect: permission denied

sudo chown $USER /var/run/docker.sock didn't help :(

financelurker commented 4 months ago

So, in total it is 2024 and still not working. This is the reason I am not using the vscode flatpak...

skyfenton commented 2 months ago

Using VSCode Flatpak to launch Podman-Remote containers for DevContainers

Overview

References

* [GitHub: flathub/com.visualstudio.code - Issue 55](https://github.com/flathub/com.visualstudio.code/issues/55#issuecomment-831234375)

* [GitHub: containers/podman - podman-remote client Tutorial](https://github.com/containers/podman/blob/main/docs/tutorials/remote_client.md)

* [GitHub: containers/podman - podman-remote-1.md](https://github.com/containers/podman/blob/main/docs/source/markdown/podman-remote.1.md)

* [VSCode - Developing in a Container](https://code.visualstudio.com/docs/remote/containers)

Setup

Install Visual Studio Code

Install Visual Studio Code and a Podman tool

➜  ~ flatpak search com.visualstudio.code
Name                                       Description                                               Application ID                                 Version                        Branch              Remotes
Visual Studio Code                         Visual Studio Code. Code editing. Redefined.              com.visualstudio.code                          1.57.1-1623936438              stable              flathub-root,flathub
Visual Studio Code (Insiders)              Visual Studio Code. Code editing. Redefined.              com.visualstudio.code.insiders                 1.61.0-1630915382              beta                flathub-beta
Code - OSS                                 Visual Studio Code. Code editing. Redefined.              com.visualstudio.code-oss                      1.47.2                         beta                flathub-beta
Podman                                     A tool for managing OCI containers and pods               com.visualstudio.code.tool.podman              3.3.1                          20.08               flathub-root,flathub
fish                                       The user-friendly command line shell                      com.visualstudio.code.tool.fish                3.3.1                          20.08               flathub-root,flathub
Code - OSS                                 Visual Studio Code. Code editing. Redefined.              com.visualstudio.code-oss                      1.60.0                         stable              flathub-root,flathub
➜  ~ flatpak --user install flathub com.visualstudio.code com.visualstudio.code.tool.podman

Override Flatpak to allow Podman Socket

See the GitHub issue for vscode flatpak issue 55.

flatpak override --user --filesystem=xdg-run/podman com.visualstudio.code

Enable Podman Socket for the User

systemctl --user enable --now podman.socket

Setup Visual Studio Code to use Podman-Remote

Install the following plugins.

flatpak run --command=bash com.visualstudio.code
code --install-extension ms-vscode-remote.vscode-remote-extensionpack

This installs the Remote Development VSCode Plugin pack to enable Container development. Now, press CTRL+SHIF+P and open Settings (UI). Search for docker and replace the docker executable word with podman-remote.

Test if podman-remote works

This was a little confusing at first, for some reason, I thought it would just use podman but it provides podman-remote.

1. Open Visual Studio Code (Flatpak).

2. Press `CTRL+(backtick)` to launch terminal.

3. Type the following
podman-remote container ls

This should show the list of Container Images, if any.

Create the DevContainer enabled project

.devcontainer/devcontainer.json

{
    "image": "docker.io/library/golang:1.16"
}

Launch code in the project with devcontainer

Inside of VSCode, open a folder. Then when prompted, Reopen folder in DevContainer.

The errors listed below should be what appear. The subsequent times I tried opening this, I could not get the logs to show. Probably has soemthing to do with a cached image, or volume.

Doesn't help the docker people, but I've been trying to get this to work for the past couple days with podman and enabling the podman socket I think did it with the other tips from @archekb and @lbssousa (specifically the symlinking the host-spawn binary to podman and then changing the docker path in vscode to "podman" from : https://discussion.fedoraproject.org/t/vscode-devcontainers/45874/12). Also for auxiliary permissions, if others need a summary, I let the flatpak have access to /tmp and also ran flatpak override --user --filesystem=xdg-run/podman com.visualstudio.code. This could be really valuable in some faq/wiki page.

samuel-garmany commented 4 days ago

Updated so I can come back to it The best solution I've found for this as of right now is to symlink your host's podman to podman in your flatpak container using this command:

mkdir -p ${HOME}/.var/app/com.visualstudio.code/data/node_modules/bin
ln -sf /app/bin/host-spawn ${HOME}/.var/app/com.visualstudio.code/data/node_modules/bin/podman

Then set your docker path to be podman.

Also I needed to open the flatpak to the tmp directory using the command

flatpak override --user --filesystem=/tmp com.visualstudio.code

Or you can just use flatseal.

This is not my favorite setup because it's not a portable vscode config and I don't like leaving scripts around but it does work with seemingly 100% functionality. Please reach out if you find a better way.

Hoping for a better solution down the line.

lbssousa commented 4 days ago

The best solution I've found for this as of right now is to put a script into your home directory that launches podman on the host. I have this one at `~/.local/bin/podman-host'

You don't even need a wrapper script for it. Since VSCode Flatpak ships host-spawn, you can now do this:

mkdir -p ${HOME}/.var/app/com.visualstudio.code/data/node_modules/bin
ln -sf /app/bin/host-spawn ${HOME}/.var/app/com.visualstudio.code/data/node_modules/bin/podman
samuel-garmany commented 4 days ago

And keep the docker path the same?

lbssousa commented 4 days ago

And keep the docker path the same?

Just podman, since ${HOME}/.var/app/com.visualstudio.code/data/node_modules/bin is already in Flatpak's PATH.