You are not logged in.
Pages: 1
Hi, I am trying to shift from Docker to Nspawn for my containers, but I have a big problem with systemd-nspawn. I have built a test container with Archlinux to try out how to run GUI applications inside containers. To enable Xorg I have followed this guide https://patrickskiba.com/sysytemd-nspaw … spawn.html
The problem is that if I run the container without --boot the applications start without problems ( I have tried cheese and galculator ), but when I run it with --boot ( starting systemd inside the container ) the GUI applications fail with the error message
"Unable to init server: Could not connect: Connection refused"
This is how I run the container
"sudo systemd-nspawn --bind=/tmp/.X11-unix --bind=/dev/shm --bind=/dev/dri --bind=/dev/nvidia0 --bind=/dev/nvidiactl --bind=/dev/nvidia-modeset -E DISPLAY=:0 -UbD ./archTest"
The container image has been built with the chroot method A https://wiki.archlinux.org/index.php/In … g_a_chroot
What I don't understand is why running systemd inside the container makes it stop running GUI applications. The host systems I have tried are Arch and Ubuntu with Wayland.
I have even tried an Ubuntu container, with the same result.
The reason I need to run it with the --boot option is because I want to be able to dynamically run applications inside the container while the container is running. Something like docker exec. And to do it I need to use systemd-run -M container_name. But systemd-run in unable to communicate with the container if itsn't running systemd.
p.s. while investigating the problem, I tried running xhost +local: in the container. Interestingly the error message is
xhost: unable to open display ""
So it seems the DISPLAY variable is cleared by systemd during the boot phase. A simple "export DISPLAY=:0" solves the problem. But it shouldn't clear the variable in the first place. After all I want to pass it the $DISPLAY value from the host. Ideas?
Last edited by pabloski (2020-12-18 18:02:49)
Offline
add
DISPLAY=:0
to
/etc/environment
inside the container
Offline
Pages: 1