Using docker in Fedora Silverblue toolbox

Hello community,

I need to deploy a dockerized demo environment.

After creating a toolbox and installing dockerinside, I get these errors. Could someone take a look to know what should I do?

Many thanks in advance,
Luis

⬢[luis@toolbox docker-teams-in-space]$ docker run hello-world
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
⬢[luis@toolbox docker-teams-in-space]$ sudo docker run hello-world
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
⬢[luis@toolbox docker-teams-in-space]$ sudo systemctl start docker
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
⬢[luis@toolbox docker-teams-in-space]$ 


It’s a known limitation of toolbox. You cannot run systemctl services within a toolbox container.
If you search in toolbox issues on Github you might find some workarounds. I’ve never experimented with it.

1 Like

Federico already made the point: toolbox has no dedicated systemd process, so this purpose is not intended (and likely to not work).

I suggest to use a virtual machine (e.g., qemu/libvirt with virt-manager: rpm-ostree install virt-manager libvirt qemu if you want to install/use that) instead of toolbox for your purpose. Then, use docker within the virtual machine.

You can try to see if podman can run the container (not in a toolbox). Podman is a backend for toolbox, and can be a drop-in replacement for some Docker images. For instance

$ podman run hello-world
2 Likes

I use docker in Toolbox but have performance issues (see Slow rootless docker performance). But I have the same performance issues using podman.

I just installed rootless docker. It is installed in the user home dir. Then you can run and access docker containers in the toolbox

Thank you very much, at last I will not use podman inside the toolbox, rotless containers or call docker on the host from the toolbox until there is a more stable solution by the distribution, so I opted by:

rpm-ostree install podman podman-docker

in the host, deploy the stack and all was fine and working.

[DELETED text to move it to another thread]

I suggest to open a new thread for your new question.

A new thread with a title fitting the new question will be more likely to get attention from users with experience in silverblue partitioning and related structures.

2 Likes

You are right, I open a new thread.

@mschwartau how did you get docker working inside the toolbox?

I installed it like described here: Run the Docker daemon as a non-root user (Rootless mode) | Docker Documentation

curl -fsSL https://get.docker.com/rootless | sh
# to start docker on start
sudo loginctl enable-linger <my username>

if you want to change to storage driver to overlay:

# you have to disable selinux
sudo rpm-ostree kargs --append=selinux=0
# change storage driver:
> cat ~/.config/docker/daemon.json 
{"storage-driver": "overlay2"}   

If you want to install docker-compose:

curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o ~/bin/docker-compose
chmod u+x ~/bin/docker-compose

You’ll have to export this env var, for example in .bashrc or .zshrc:

export DOCKER_HOST=unix:///run/user/1000/docker.sock

You can start docker containers from toolbox:

mschwartau@toolbox:pts/0->/var/home/mschwartau (0) 
> docker run --rm ubuntu echo "Hello" 
Hello

Note that rootful docker will not work in toolbox: Cannot use the host's Docker socket · Issue #430 · containers/toolbox · GitHub. But with rootless I haven’t had any problems (except the performance problems, see thread. But podman has the same performance problems.

Regards
Meinert

1 Like