Running docker in fedora-toolbox

Currently I am using Silverblue 30 and all my development tools are layered (I am aware it is not the best thing to do).
The only thing holding me back to use fedora-toolbox for development is running docker inside toolbox.
So, is there a way to run docker/moby-engine inside the fedora-toolbox?

This is how my layered packages mess looks like:

Deployments:
โ— ostree://fedora-workstation:fedora/30/x86_64/silverblue
               Version: 30.20190427.n.0 (2019-04-27T08:57:18Z)
            BaseCommit: a602958b1097d0790361a8b907f6f6ecbb62b7bbf826b086401eafb4ffcb845d
          GPGSignature: Valid signature by F1D8EC98F241AAF20DF69420EF3C111FCFC659B9
       LayeredPackages: adapta-gtk-theme chromium chromium-libs-media-freeworld clang code fish
                        gcc 'gcc-c++' gnome-tweaks htop java-openjdk java-openjdk-devel
                        libappindicator-gtk3 'libstdc++.i686' moby-engine nodejs
                        papirus-icon-theme redhat-rpm-config ruby ruby-devel vim virt-manager
         LocalPackages: rpmfusion-free-release-30-1.noarch rpmfusion-nonfree-release-30-1.noarch

And yes I use moby-engine instead of docker-ce

Update:
I moved my dev-env in toolbox and I am using moby-engine as layered.
Another question is there any way to run a program directly from host inside toolbox? For example, rather than doing toolbox enter and then vim , is there anything like toolbox exec vim ?

1 Like

I donโ€™t know if this will work for moby-engine, but it is possible to run commands on the host via flatpak-spawn --host. Iโ€™ve not used it myself, but there are other threads on this forum using this approach.

2 Likes

Yes flatpak-spawn --host worked for me!!

Thanks!

But what about running a process directly from host?

flatpak-spawn --host from inside the toolbox container should spawn a process directly on the host.

Am I mis-understanding your question?

Yes flatpak-spawn --host works for spawning a host process, but what I want is running container process from host without doing toolbox enter everytime.

You can run container processes with podman from the host. It should be a near identical drop-in for docker, if you have used that before.

Does that answer your question?

Yes I am aware about podman and I know that toolbox uses it to create a container but toolbox enter also adds some ENV variables and other stuff when doing toolbox enter.

For example running podman exec returns this:

$ podman exec -it 84d9dbd32762 env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TERM=xterm
HOSTNAME=toolbox
container=podman
FGC=f30
NAME=fedora-toolbox
VERSION=30
DISTTAG=f30container
HOME=/home/rajveer

but toolbox enter and then env returns this:

$ toolbox enter
$ env
COLORTERM=truecolor
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DESKTOP_SESSION=gnome
DISPLAY=:0
DISTTAG=f30container
FGC=f30
GOPATH=/home/rajveer/go
HOME=/home/rajveer
HOSTNAME=toolbox
LANG=en_US.UTF-8
NAME=fedora-toolbox
NPM_CONFIG_PREFIX=/home/rajveer/.npm-global
OLDPWD=/var/home/rajveer
OMF_CONFIG=/home/rajveer/.config/omf
OMF_PATH=/home/rajveer/.local/share/omf
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/rajveer/.local/bin:/home/rajveer/bin:/usr/bin:/usr/sbin:/home/rajveer/go/bin:/usr/local/go/bin:/home/rajveer/.npm-global/bin
PS1=๐Ÿ”น[\u@\h \W]\$ 
PWD=/home/rajveer
SHELL=/usr/bin/fish
SHLVL=1
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
TERM=xterm-256color
USER=rajveer
VERSION=30
VTE_VERSION=5601
XDG_CURRENT_DESKTOP=GNOME
XDG_DATA_DIRS=/home/rajveer/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/
XDG_MENU_PREFIX=gnome-
XDG_RUNTIME_DIR=/run/user/1000
XDG_SEAT=seat0
XDG_SESSION_DESKTOP=gnome
XDG_SESSION_ID=2
XDG_SESSION_TYPE=wayland
XDG_VTNR=2
container=podman

This happens because toolbox adds many other arguments when doing toolbox enter to the podman exec command, this is what I got by doing a simple ps fax

podman exec --env=COLORTERM=truecolor --env=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus --env=DESKTOP_SESSION=gnome --env=DISPLAY=:0 --env=LANG=en_US.UTF-8 --env=SHELL=/usr/bin/fish --env=SSH_AUTH_SOCK=/run/user/1000/keyring/ssh --env=TERM=xterm-256color --env=VTE_VERSION=5601 --env=XDG_CURRENT_DESKTOP=GNOME --env=XDG_DATA_DIRS=/home/rajveer/.local/share/flatpak/exports/share/:/var/lib/flatpak/exports/share/:/usr/local/share/:/usr/share/ --env=XDG_MENU_PREFIX=gnome- --env=XDG_RUNTIME_DIR=/run/user/1000 --env=XDG_SEAT=seat0 --env=XDG_SESSION_DESKTOP=gnome --env=XDG_SESSION_ID=2 --env=XDG_SESSION_TYPE=wayland --env=XDG_VTNR=2 --interactive --tty fedora-toolbox-rajveer-30 capsh --caps= -- -c cd "$1"; export PS1="$2"; shift 2; exec "$@" /bin/sh /home/rajveer ๐Ÿ”น[\u@\h \W]\$  /usr/bin/fish -l
1 Like