Running GUI app inside LXC Container

I would like to run several GUI apps inside a variety (openSUSE and Ubuntu) of LXC containers.

I googled this and tried following several non-nixos specific guides without success. Is anyone aware of nixos based guides on how to do this, or able to share how this is done?

I’m running latest nixos 22.11 with Gnome.

1 Like

I think the most important bit is to make X11 and/or Wayland sockets of the host available in the container. That is mounting the actual socket in the container filesystem and setting the ENV variable in the container accordingly.

Is is described here for nixos containers here Application Isolation using NixOS Containers · Marcin Sucharski

Hope that helps a bit.

1 Like

its tough with docker, it’s tough with any type of container.

@matthewcroughan , had done a lot around this area… it’s possible but it’s hacky.

can i ask what your use case is? i’m also interested on the how and why programmers are using containers.

Thank you for the reply and the link. It more comprehensively highlights the things to attend to.

I will try to apply these details in my situation and provide an update.

I want to access certain applications that aren’t officially supported on nixos to support development activities.

I have tried setting up the applications on nixos and been unsuccessful resolving the issues that arose.

As an example, TWS from IBKR doesn’t install and run. It complains about the architecture when trying to install the Java that is bundled with the install and doesn’t work if I install Java myself on nixos.

Also, I would prefer to run the self updating version of the application if possible which defeats the declarative benefits of nixos. As such, it seems that if I can host the app in a container that matches the Linux flavour preferred by the app, then I may be able to derive all the benefits of nixos on the host while still be able to access a collection of applications staged in Linux environments that more closely match production.

Other than that, it seems like it would be a neat thing to do :slight_smile:

Thx

I usually put podman and and distrobox to work for that use case, not only on NixOS, but also e.g. to run yocto builds in a LTS-Ubuntu while being on the latest Ubuntu (with podman/distrobox provided by a Nix-devshell).

Thanks, I’ve never used those before and will look at that option as well.

sounds like you fighting a few battles there!!

Well I got it working really well but now I’m ironing out refinements.

Once, I’m done I’ll post the recipe.

2 Likes

Were you able to get a recipe finished?

Yes with varying degrees of success. I was able to get a java based trading solution to work fine but unable to get a javascript solution working. I’ll review what I did for the java solution and post it if you are interested.

1 Like

have you tried possible remote desktop solution? (e.g xrdp, vnc protocols)
e.g: GitHub - JimJ92120/nixos-remote-desktop-for-lxd: Demonstrate how to build and run a NixOS Desktop as a container for LXD.

run several GUI apps inside a variety (openSUSE and Ubuntu) of LXC containers

Unless this refers to “running a limited set of GUI apps”?
Possibly “kiosk-mode” like, along with remote desktop?
I believe there are existing solutions that only need to be translated into “nix”

Thanks for your response.

This issue occured over a year ago and I was able to configure the LXC container to use the hosts X environment resulting in excellent performance for two of the applications.

Subsequently, I had the thought of trying to use buildFHSUserEnv to see if I could get the applications to run natively. I haven’t had a chance to try that but it’s on my list :slight_smile:

what solutions did you end up with?
any issues with wayland? X11 being more mature

i have similar use cases with embedded systems so i’m quite curious (to avoid running a full / semi desktop solutions)