Skip to content

Support Toolbox (a.k.a. Fedora Toolbox) #3345

Open

Description

Since Remote Containers extension actually supports Podman container runtime, I would like to go a step further and support container environments provided by Toolbox (do not confuse with Docker Toolbox).

Toolbox is a wrapper tool for Podman that allows creating and entering mutable containerized environments. I seems something like WSL approach, but for OCI containers via Podman.

There's already a way to connect VSCode to a Toolbox environment via Remote SSH extension, using this workaround, but I want to do the same directly via Remote Containers extension (or maybe a new Remote Toolbox one)

Maybe Debarshi Ray (@debarshiray) could provide more info about what's needed to add Toolbox support to VSCode Remote Development extensions.

Activity

  1. added
    containers
    on Jul 10, 2020
  2. chrmarti commented on Aug 6, 2020

    @chrmarti
    Contributor

    Since it is a wrapper: Can the podman CLI be used to access it? If so, it should already be possible to connect to it with Remote-Containers.

  3. added
    feature-request
    on Aug 6, 2020
  4. DMouse10462 commented on Aug 12, 2020

    @DMouse10462

    Can the podman CLI be used to access it?

    Yes, you can access it just like any regular container. I'm not the issue submitter, but I can share some of what I encounter when trying to connect to an existing toolbox.

    Some basic info for my setup:
    OS: Fedora Workstation 32
    $ podman -v: podman version 2.0.4

    Logs from attempting to connect to a Fedora 32 toolbox named grails-dev:

    [34 ms] Start: Resolving remote
    [38 ms] Setting up container grails-dev
    
    [39 ms] Start: Run: podman inspect --type container grails-dev
    [297 ms] Start: Check Docker is running
    [298 ms] Start: Run: podman info
    [741 ms] Start: Inspecting container
    [742 ms] Start: Run: podman inspect --type container ca9d153d0a5c2b4191be68bb3244b700416a87f5682b3db47b1f7f3a18dddcb7
    [1190 ms] Start: Run: podman exec -i -u root -e VSCODE_REMOTE_CONTAINERS_SESSION=f54745c4-c0f0-4f9b-80be-0274471e9fbc1597217678921 ca9d153d0a5c2b4191be68bb3244b700416a87f5682b3db47b1f7f3a18dddcb7 /bin/sh
    [1232 ms] Start: Run in container: uname -m
    [1609 ms] x86_64
    [1609 ms] 
    [1610 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
    [1614 ms] NAME=Fedora
    VERSION="32 (Container Image)"
    ID=fedora
    VERSION_ID=32
    VERSION_CODENAME=""
    PLATFORM_ID="platform:f32"
    PRETTY_NAME="Fedora 32 (Container Image)"
    ANSI_COLOR="0;34"
    LOGO=fedora-logo-icon
    CPE_NAME="cpe:/o:fedoraproject:fedora:32"
    HOME_URL="https://fedoraproject.org/"
    DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
    SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    REDHAT_BUGZILLA_PRODUCT="Fedora"
    REDHAT_BUGZILLA_PRODUCT_VERSION=32
    REDHAT_SUPPORT_PRODUCT="Fedora"
    REDHAT_SUPPORT_PRODUCT_VERSION=32
    PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
    VARIANT="Container Image"
    VARIANT_ID=container
    [1614 ms] 
    [1614 ms] Start: Run in container: cat /etc/passwd
    [1620 ms] Start: Run in container: test -d /root/.vscode-server-insiders
    [1624 ms] 
    [1624 ms] 
    [1625 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server-insiders/data/Machine' && { > '/root/.vscode-server-insiders/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
    [1632 ms] 
    [1632 ms] 
    [1632 ms] Exit code 1
    [1633 ms] Start: Run in container: test -d /root/.vscode-server-insiders/bin/2277c8e2a3e1cc630a6397301ba54a1dccd8a60d
    [1639 ms] 
    [1639 ms] 
    [1639 ms] Start: Launching Remote-Containers helper.
    [1642 ms] Start: Run: gpgconf --list-dir agent-extra-socket
    [1659 ms] Start: Run in container: gpgconf --list-dir agent-socket
    [1662 ms] /root/.gnupg/S.gpg-agent
    [1663 ms] 
    [1663 ms] Start: Run in container: gpgconf --list-dir homedir
    [1667 ms] /root/.gnupg
    [1667 ms] 
    [1667 ms] Start: Run in container: ls '/root/.gnupg/private-keys-v1.d' 2>/dev/null
    [1672 ms] 
    [1672 ms] 
    [1672 ms] Exit code 2
    [1672 ms] Start: Run in container: mkdir -p -m 700 '/root/.gnupg'
    [1680 ms] 
    [1680 ms] 
    [1680 ms] Start: Run in container: command -v git >/dev/null 2>&1 && git config --global credential.helper '!f() { /root/.vscode-server-insiders/bin/2277c8e2a3e1cc630a6397301ba54a1dccd8a60d/node /tmp/vscode-remote-containers-d8def71c0ee26c51418e0da1049888df62f6a191.js $*; }; f' || true
    [1683 ms] Start: Run: gpgconf --list-dir homedir
    [1699 ms] 
    [1699 ms] 
    [1700 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-d8def71c0ee26c51418e0da1049888df62f6a191.js' >/tmp/vscode-remote-containers-d8def71c0ee26c51418e0da1049888df62f6a191.js
    [1709 ms] 
    [1709 ms] 
    [1709 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server-insiders/data/Machine' && { > '/root/.vscode-server-insiders/data/Machine/.installExtensionsMarker' ; } 2> /dev/null
    [1718 ms] 
    [1721 ms] 
    [1721 ms] Exit code 1
    [1721 ms] Start: Run in container: cat <<'EOF-/tmp/vscode-remote-containers-server-d8def71c0ee26c51418e0da1049888df62f6a191.js' >/tmp/vscode-remote-containers-server-d8def71c0ee26c51418e0da1049888df62f6a191.js
    [1767 ms] 
    [1767 ms] 
    [1767 ms] Start: Run in container: gpgconf --list-dir homedir
    [1767 ms] Start: Run: podman exec -i -u root -e REMOTE_CONTAINERS_SOCKETS=["/tmp/vscode-ssh-auth-d8def71c0ee26c51418e0da1049888df62f6a191.sock","/root/.gnupg/S.gpg-agent"] -e REMOTE_CONTAINERS_IPC=/tmp/vscode-remote-containers-ipc-d8def71c0ee26c51418e0da1049888df62f6a191.sock ca9d153d0a5c2b4191be68bb3244b700416a87f5682b3db47b1f7f3a18dddcb7 /root/.vscode-server-insiders/bin/2277c8e2a3e1cc630a6397301ba54a1dccd8a60d/node /tmp/vscode-remote-containers-server-d8def71c0ee26c51418e0da1049888df62f6a191.js
    [1797 ms] /root/.gnupg
    [1797 ms] 
    [1797 ms] Start: Run in container: for pid in `cd /proc && ls -d [0-9]*`; do { echo $pid ; readlink -f /proc/$pid/cwd ; xargs -0 < /proc/$pid/environ ; xargs -0 < /proc/$pid/cmdline ; } ; echo ; done 2>/dev/null
    [1816 ms] Start: Run: gpg-connect-agent updatestartuptty /bye
    [2301 ms] Remote-Containers server: Error: open executable: Permission denied: OCI runtime permission denied error
    [2416 ms] Remote-Containers server terminated (code: 126, signal: null).
    [3446 ms] Start: Run in container: /root/.vscode-server-insiders/bin/2277c8e2a3e1cc630a6397301ba54a1dccd8a60d/server.sh --disable-user-env-probe --use-host-proxy --port 0 --extensions-download-dir /root/.vscode-server-insiders/extensionsCache
    [3458 ms] Error: stream is closed
            at /home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:208142
            at c (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:224558)
            at EventEmitter.e.<computed> [as exec] (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:224281)
            at u (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:202138)
            at new Promise (<anonymous>)
            at /home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:202116
            at J (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:81982)
            at W (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:81174)
            at processTicksAndRejections (internal/process/task_queues.js:85:5)
            at async Object.t.injectIntoContainer (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:77410)
            at async Object.t.resolve (/home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:238639)
            at async /home/dmouse/.vscode-insiders/extensions/ms-vscode-remote.remote-containers-0.134.0/dist/extension.js:1:688588
    

    When I manually go into the toolbox and attempt to run the server.sh command (as root within the container due to permission issues; the toolbox command usually drops you to a UID 1000 shell with sudo privileges), the server appears to start correctly unlike the output within VS code. Here's the output of me running the command within a toolbox enter shell (Addendum: the same results occur when entering via podman exec and running the command directly as root):

    ⬢[dmouse@toolbox ~]$ sudo /root/.vscode-server-insiders/bin/2277c8e2a3e1cc630a6397301ba54a1dccd8a60d/server.sh --disable-user-env-probe --use-host-proxy --port 0 --extensions-download-dir /root/.vscode-server-insiders/extensionsCache
    
    
    *
    * 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
    *
    
    
    IP Address: <MY HOST IP>
    Extension host agent listening on 34411
    
    
    [03:44:20] Extension host agent started.
    Unable to retrieve mac address (Error: Command failed: /sbin/ifconfig -a || /sbin/ip link
    /bin/sh: /sbin/ifconfig: No such file or directory
    /bin/sh: /sbin/ip: No such file or directory
    )
    ^C
    ⬢[dmouse@toolbox ~]$ id
    uid=1000(dmouse) gid=1000(dmouse) groups=1000(dmouse),10(wheel)
    

    It is worthy of note that the IP address shown is the address of the host despite running within a container; the user's home directory is mounted in a toolbox and the container appears to be running in host networking mode (?). I'm not 100% sure of what else toolbox sets up the container with.

  5. lbssousa commented on Aug 13, 2020

    @lbssousa
    Author

    Debarshi Ray (@debarshiray), could you give us any useful info about Toolbox here?

  6. debarshiray commented on Sep 8, 2020

    @debarshiray

    Very excited to see the interest in Toolbox here!

    Toolbox containers are just OCI containers created, managed and run by Podman under the hood. Toolbox is a thin wrapper around Podman to set up the containers in a way that makes it easy to use them as pet development environments without being burdened by the cognitive load of being inside a container.

    Assuming that you have already created a container (with toolbox create ...), entering or using the container is a matter of:

    • Calling the org.freedesktop.Flatpak.SessionHelper.RequestSession D-Bus method
    • Starting the container with podman start ... and waiting for the entry-point to have performed some run-time configuration
    • Entering it with podman exec ...

    I hope that this gives you some idea about what happens underneath the toolbox enter command.

    I am happy to answer more specific questions.

  7. likan999 commented on Oct 20, 2020

    @likan999

    I have a PR for toolbox to make it work: containers/toolbox#587. With the patch, on your local machine, you only need an alias in ~/.ssh/config that has RemoteCommand toolbox run -T bash and everything just works as a normal SSH remote host. Of course VScode could do fancier stuff (e.g. without need to manually modify the ssh config) but at least it is no longer blocked on the toolbox side.

  8. likan999 commented on Oct 22, 2020

    @likan999

    To clarify, my approach is different to the workaround mentioned in the top. The workaround starts an openssh server inside the toolbox, while my approach doesn't rely on any service running inside the toolbox.

  9. lbssousa commented on Oct 27, 2020

    @lbssousa
    Author
    * Calling the `org.freedesktop.Flatpak.SessionHelper.RequestSession` D-Bus method
    
    * Starting the container with `podman start ...` and waiting for the entry-point to have performed some run-time configuration
    
    * Entering it with `podman exec ...`
    

    Christof Marti (@chrmarti) , can these steps (specially the first one) be performed with current Remote Containers implementation, or there's some lacking piece?

  10. chrmarti commented on Oct 27, 2020

    @chrmarti
    Contributor

    Laércio de Sousa (@lbssousa) There is "initializeCommand" in the devcontainer.json that runs before anything else. We support Podman with a setting for the Docker executable that can be set to podman. We then start the container with podman run and connect to it with podman exec. Not sure what the entry-point needs to do, but you might need to turn off our overriding of it with "overrideCommand": false in the devcontainer.json (and then make sure the container still keeps running).

  11. lbssousa commented on Oct 28, 2020

    @lbssousa
    Author

    Christof Marti (@chrmarti), I was able to attach to my Toolbox container with the following minimal devcontainer.json:

    {
      "name": "Toolbox",
      "image": "registry.fedoraproject.org/f33/fedora-toolbox:33",
      "initializeCommand": "gdbus call --session --dest org.freedesktop.Flatpak --object-path /org/freedesktop/Flatpak/SessionHelper --method org.freedesktop.Flatpak.SessionHelper.RequestSession"
      "overrideCommand": false // I see no difference in setting this option or not
    }

    However, VSCode always connect to that container as root (remoteUser does not work for me, since it seems my host user is not actually created inside the container: toolbox enter still does some magic to make my host user available to the container).

    Debarshi Ray (@debarshiray), is there something else I need to do? What shoud I do with the output of gdbus call ... org.freedesktop.Flatpak.SessionHelper.RequestSession command?

    EDIT: My mistake. With the approach above, I'm not attaching to the same container created by toolbox create, but, instead, creating a new container from the same image. When I try to attach to the correct Toolbox container, I get the same error reported earlier:

    Remote-Containers server: Error: open executable: Permission denied: OCI runtime permission denied error
    
  12. debarshiray commented on Oct 29, 2020

    @debarshiray

    What shoud I do with the output of gdbus call ... org.freedesktop.Flatpak.SessionHelper.RequestSession
    command?

    Note that this isn't necessary any more for Toolbox containers created with current toolbox.git, which will be released as Toolbox 0.0.97.

    It's possible to detect whether it's necessary or not by running podman inspect on the container and checking if it bind mounts anything at /run/host/monitor.

    The overall idea was to somehow keep the time zone configuration of the container synchronized with the host. So far, Toolbox made use of the flatpak-session-helper utility to keep a copy of the host's configuration files in $XDG_RUNTIME_DIR/.flatpak-helper/. This location was then bind mounted inside the container at /run/host/monitor, and symbolic links were set up inside the container's /etc.

    Most of this is done as part of the podman create ... call that creates the Toolbox container, and the entry point of the container itself. However something needs to launch the flatpak-session-helper before starting the container so that things are available in $XDG_RUNTIME_DIR/.flatpak-helper/, and this is what that gdbus call ... command does.

  13. debarshiray commented on Oct 29, 2020

    @debarshiray

    Remote-Containers server: Error: open executable: Permission denied: OCI runtime
    permission denied error

    This could be Podman territory, but we need some more information to be sure. Which is the exact command that's failing?

    I don't know very well how vscode-remote-release works, so I will throw some more information out there. :)

    All Toolbox containers have their entry points set to toolbox init-container .... This is important because it's used to self-configure the container at run-time. Yes, /usr/bin/toolbox is also the entry point. This is achieved by bind mounting /usr/bin/toolbox from the host into the container and then using it.

    /usr/bin/toolbox enter uses podman start ... to start the container and then podman exec ... to enter it. If you are instead using podman run ... to start the container, then that might be running into some problems. It might be possible to navigate them, but it might also be better to just use podman start ... if that's possible.

    Note that the podman exec ... invocation also takes a long list of arguments that includes environment variables and what not.

    Would it somehow be possible to just use toolbox enter to enter the container?

  14. chrmarti commented on Oct 29, 2020

    @chrmarti
    Contributor

    We are trying to stay out of adaptions specific to one CLI or runtime. Podman-support comes from Podman's CLI being compatible with the Docker CLI, so we didn't have to change much (except for the version check).

  15. 18 remaining items

  16. chrmarti commented on Nov 13, 2020

    @chrmarti
    Contributor

    Did you rebuild the container after changing containerEnv? I had unsetting working, try setting it to the desired path if it doesn't.

  17. lbssousa commented on Nov 13, 2020

    @lbssousa
    Author

    No, I didn't rebuilt my container after setting "containerEnv". I tried both empty string and my home folder path, but none of tem has worked.

    TBH, I'm not worried about this anymore: keeping .vscode-server under /root folder within the container allows me not leaking it to my host system's home folder.

  18. lbssousa commented on Nov 14, 2020

    @lbssousa
    Author

    There's one last thing that still makes me unconfortable with this solution: since Toolbox is a very special case of container-based development, in which host system's user home folder is directly bound to the container, Remote-Containers extension ends up overwriting my ~/.gitconfig's credential.helper value, replacing the original value (e.g. store) with something like "!f() { /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/node /tmp/vscode-remote-containers-0f1183fad6e028a06ad0d6f114ae48cb785a1d17.js $*; }; f". Is there a way to prevent this?

  19. chrmarti commented on Nov 16, 2020

    @chrmarti
    Contributor

    There is a Remote-Containers setting to turn this off.

  20. lbssousa commented on Nov 16, 2020

    @lbssousa
    Author

    Oh, I've just found it here. Thanks!

    For anyone interested, I've summarized my configuration to make Remote-Containers work with my Toolbox container here.

  21. debarshiray commented on Nov 17, 2020

    @debarshiray

    It's really amazing that you have managed to get this far!

    The part about HOME being set to /root makes me curious. A Toolbox container uses two UIDs. One is UID 0. This isn't the actual UID 0 on the host, but some other UID on the host mapped to 0 inside the container's user namespace. This is used to run the container's entry point. I believe this is why you see the HOME=/root. The other is the user's own UID which is the same both on the host and in the container. This is what is used to present the shell to the user.

    Is Visual Studio Code going by the HOME it sees in the podman inspect output when trying to place the .vscode-server directory?

  22. chrmarti commented on Nov 17, 2020

    @chrmarti
    Contributor

    Debarshi Ray (@debarshiray) Yes, we first look at HOME from podman inspect. If that is not set we look up it in /etc/passwd. Note that we install and run the server as the remoteUser which might run into permission issues under /root.

  23. lbssousa commented on Nov 17, 2020

    @lbssousa
    Author

    Does Remote-Containers extension currently support property name for attached container config? I'm trying to customize my Toolbox display name in VSCode, but it's not working.

    If not, could you amend it to issue #4013?

  24. lbssousa commented on Nov 19, 2020

    @lbssousa
    Author

    I guess we have now all the needed information for an eventual solution on the Toolbox side (auto-generating the needed configuration for Remote-Containers). I've opened an issue there. If Debarshi Ray (@debarshiray) has no other questions, I believe this issue can be closed now.

  25. removed their assignment
    on Mar 26, 2021
  26. alvarlagerlof commented on Oct 26, 2021

    @alvarlagerlof

    Sorry for the ping, but I'm seeing a lot of issues here and I'm having trouble making sense of what works and what doesn't. Is there an updated guide/text on what works and how to set that up?

  27. lbssousa commented on Oct 26, 2021

    @lbssousa
    Author
  28. alvarlagerlof commented on Oct 31, 2021

    @alvarlagerlof

    Alvar Lagerlöf (@alvarlagerlof) The most up-to-date solution about this issue is a third-party project: https://github.com/owtaylor/toolbox-vscode

    That does not work anymore. Any alternatives?

  29. heyakyra commented on Jan 15, 2022

    @heyakyra

    This might finally get me to switch to kakoune Helix / Lapce with zellij + tmate

  30. daw1012345 commented on Apr 16, 2023

    @daw1012345

    Almost 3 years after this issue was originally created I ran into problems trying to use Toolbox containers and VScode together. https://github.com/owtaylor/toolbox-vscode doesn't seem to be working and other articles on the topic caused other (permission) issues for me. I decided to write an updated script that works well enough for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

containersfeature-request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions