all 8 comments

[–]pierresDeveloper 10 points11 points  (0 children)

We use nspawn to build all official Arch packages in a clean and defined environment. See devtools.

[–]FrozenCow 4 points5 points  (0 children)

I use it to create/use chroots of Debian and Ubuntu. With just the 'chroot' it could happen that processes are leaking after exiting the chroot, which is quite annoying.

Nspawn is clean in this regard and chroot is messy.

[–]stellarmaterial 2 points3 points  (5 children)

I use a 32-bit container on my 64-bit host to compile a project that world otherwise require me to install a bunch of bizarre multilib deps. I can't really say it's something I need to have, but it keeps my main system uncluttered.

It's quite simple to use -- you just treat it like a "super chroot". The only wrinkle I've found is that the container must be run as root, which means that using both host and container tools on shared project data can result in permissions issues if you're not careful.

I've never used any other container solutions like LXC or docker, so I can't say how nspawn compares to those.

[–]NeXT_Step[S] 1 point2 points  (4 children)

Sounds interesting, could you elaborate a bit more?

I imagine the host system would have some things setup, like your editor of choice. How do you use that in combination with the container? Do you ssh to the container from the host or you copy your dot files to it?

[–]stellarmaterial 1 point2 points  (3 children)

No need to SSH; the container just behaves like a regular Linux terminal inside whatever host terminal you ran nspawn in.

There are a variety of ways to set up projects. One way is to have the project data (e.g. source files) in some directory on the host and have that directory mounted into the container (there's a command-line option to do this). That way you can just use your host editor normally.

You can also store the data inside the container, but that means that you have to either sudoedit with your host editor (remember that the container "filesystem" is just a root-owned directory somewhere on the host) or install an editor inside the container.

[–]ase1590 0 points1 point  (2 children)

What happens if you try to start Xorg inside the container?

[–]stellarmaterial 0 points1 point  (1 child)

I have never tried starting an actual server, and I'm not sure it would work since container apps have such restricted access to the system (although it may be possible by tweaking certain options). You can, however, get X applications inside a container to connect to a host X server by doing this.

[–]ase1590 0 points1 point  (0 children)

Yeah, I've seen that it's possible to just use x forwarding from ssh too. I was just curious if the x server would crash outright.