Questions tagged [systemd-nspawn]

For questions pertaining to systemd-nspawn, a utility to spawn a command or OS in a light-weight container. Use this tag for questions about systemd-nspawn itself, using systemd-nspawn, or questions about issues arising inside a container spawned by systemd-nspawn where that is significant.

Filter by
Sorted by
Tagged with
0 votes
0 answers
54 views

Exposing a systemd service to systemd-nspawn container

I have a system with a bunch of services running on them. Some tasks require the ability to stop and start these services. Given an nspawn container running on a host, is there any way whatsoever to ...
user avatar
  • 53
0 votes
0 answers
63 views

Why do systemd-nspawn's network namespaces not work correctly without systemd running inside the container?

I am trying to run a systemd-nspawn container without an init system and inside of a systemd-nspawn-managed network namespace. My container is a stock Fedora 35 image, and I am invoking it like so: ...
user avatar
2 votes
1 answer
99 views

How do I wait for a systemd-nspawn container to boot?

I have a script that contains the following: sudo machinectl start "$machinename" sudo systemd-run -PM root@"$machinename" "$command" Failed to connect to bus: No such ...
user avatar
  • 23
0 votes
0 answers
57 views

How to resolve a systemd-nspawn container?

I have a nspawn container: root@nomad-02:~# machinectl list MACHINE CLASS SERVICE OS VERSION ADDRESSES debian container systemd-nspawn debian 11 192.168.88.171… 1 machines listed....
user avatar
1 vote
1 answer
185 views

Start Desktop Environment From Chroot

Is it possible to start a desktop environment entirely in systemd-nspawn or chroot? I want to be able to boot to a console, then optionally enter a chroot and launch Gnome or another desktop ...
user avatar
0 votes
1 answer
101 views

What can happen if you rm -rf a systemd-nspawn container directory from host while running?

I was running a systemd-nspawn container with command: systemd-nspawn --console=passive -qbUD container-directory 2>&1 >/dev/null & to provide a clean build environment. While cleaning ...
user avatar
3 votes
1 answer
1k views

Why systemd-nspawn is slower than docker,podman and qemu?! how to Improve nspawn performance?

Why nspawn is slow compared to docker podman and even qemu?! CPU tasks take twice of the time it takes in docker, podman or qemu Here is a benchmark test I did: First I disabled all the spectre/...
user avatar
0 votes
0 answers
157 views

Use adb (android debug bridge) in systemd-nspawn container

I would like to use adb inside an systemd-nspawn container. Unfortunately I cannot access the phone inside the container (connected via USB). pi@debian-buster-64:~ $ export ADB_TRACE=usb pi@debian-...
user avatar
1 vote
2 answers
1k views

How to debootstrap Centos?

Is there a way to create a Centos system inside a chroot using something similar to debootstrap for Debian/Ubuntu? I’d need it for a container project where Docker is NOT a solution(I’d use systemd ...
user avatar
  • 175
1 vote
0 answers
2k views

hostnamectl fails with “Connection timed out” when running inside a systemd-nspawn container

I’m using systemd-nspawn and qemu-arm-static to boot into a Raspberry Pi OS image to apply customizations to the stock image before flashing it onto an SD card. The host machine is Ubuntu 20.10 (...
user avatar
  • 111
1 vote
0 answers
1k views

How to disable X11 extension (MIT-SHM) for systemd-nspawn container?

X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 130 (MIT-SHM) Minor opcode of failed request: 3 (X_ShmPutImage) Value in ...
user avatar
  • 142
1 vote
0 answers
194 views

How to pass environment variables to systemd-nspawn container?

$ systemd-nspawn -bUM $container -E DISPLAY="$DISPLAY" > (...) $ cat /proc/1/environ > (...) DISPLAY=:0 But echo $DISPLAY outputs nothing, since the variable is passed to systemd ...
user avatar
  • 142
1 vote
2 answers
629 views

Install Debian Package in chroot

I am building a minimal Debian image with debootstrap, chroot in it and installing grub. Now I need to install some custom self created debian packages. These packages have postinst scripts running ...
user avatar
  • 111
12 votes
1 answer
2k views

How can I make a device available inside a systemd-nspawn container with user namespacing?

I would like to mount an encrypted image file using cryptsetup inside a systemd-nspawn container. However, I get this error message: [root@container ~]# echo $key | cryptsetup -d - open luks.img luks ...
user avatar
  • 736
1 vote
1 answer
1k views

Booting a systemd container - how to bypass console login?

I am using systemd-nspawn to boot a linux container and load its lxsession in a VNC-style nested X server. (Xephyr) I have created a script to do this. One of the main problems with the script is the ...
user avatar
  • 141
1 vote
1 answer
419 views

Systemd-nspawn boot container, then run lxsession automatically; How to do this?

I am making a script that uses systemd-nspawn to boot a second linux root filesystem in a container. The script is currently using this line to boot the container: systemd-nspawn -b --machine ...
user avatar
  • 141
0 votes
1 answer
695 views

Manage a systemd-nspawn container as a systemd unit

Question How do I manage a systemd-nspawn container as a systemd unit? Setup Install an image # machinectl pull-raw --verify=no https://ftp.halifax.rwth-aachen.de/fedora/linux/releases/30/Cloud/...
user avatar
  • 2,546
3 votes
1 answer
217 views

PLATFORM variable for qemu / system-nspawn

I'm customizing a Raspbian installation using qemu, i.e.: systemd-nspawn -q --bind /usr/bin/qemu-arm-static -D $MOUNTPATH /bin/bash << EOF DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND ...
user avatar
  • 557
2 votes
1 answer
1k views

systemd-nspawn/machinectl and macvlan

I would like to create a nspawn container connected to the network via macvlan and dhcp. All documentation I have found were very instructive but did not offer a step by step procedure for this setup. ...
user avatar
  • 21
-3 votes
1 answer
475 views

What is "a light-weight namespace container" created by systemd-spawn?

man systemd-nspawn says systemd-nspawn may be used to run a command or OS in a light-weight namespace container. In many ways it is similar to chroot(1), but more powerful since it fully ...
user avatar
  • 89.8k
6 votes
1 answer
1k views

Why does `systemd-nspawn -n` network namespace not show in `ip netns list`?

tl;dr Linux has namespaces, in particular, network namespaces. It seems the namespace supposedly created via the -n flag when running systemd-nspwawn does not show up when employing ip netns list (...
user avatar
2 votes
0 answers
28 views

How to ensure a container is started after another?

I use systemd-nspawn to run containers. There are mostly independent, except for two which should be started one after the other. Is there a way to ensure this? Something similar to After= for ...
user avatar
  • 1,268
7 votes
0 answers
1k views

systemd-nspawn: how to allow access to all devices?

I'm trying to create a rough equivalent of Docker's --privileged in a systemd container, but I've got no idea how to allow the container to access all of the devices available on the host (without ...
user avatar
  • 141
2 votes
1 answer
1k views

How to make systemd-nspawn work with ufw firewall?

I'm running a systemd-nspawn container (Debian 9, host also Debian 9) with VirtualEthernet=yes and some ports forwarded, e.g. Port=tcp:443:443. I.e. a web server runs in the container and should be ...
user avatar
  • 21
2 votes
2 answers
5k views

Running systemd utilities like systemctl under an nspawn?

If I have a directory that I bootstraped with debootstrap that I got inside of running systemd-nspawn what do I have to do make its internal systemd functional? $ sudo systemd-nspawn -D ./foo ...
user avatar
  • 22.4k
2 votes
2 answers
2k views

systemd-nspawn vs chroot and bind mount?

Does systemd-nspawn do special inside to a chroot or does it just provide a different method of running chroot + the appropriate ro --bind mounts for proc, sys. The docs say, similar to chroot(1), ...
user avatar
  • 22.4k
2 votes
1 answer
1k views

CPU usage limit to systemd-nspawn container is not working

I am using systemd-nspawn(systemd version 237) in Yocto's embedded Linux environment. This is the content of /etc/systemd/system/systemd-nspawn\@.service.d/override.conf file ExecStart=/usr/bin/...
user avatar
  • 61
0 votes
1 answer
164 views

non-interactive password change of nspawn container

I want to change passwd of root of nspawn container, as I am creating container via ansible just after I created rootfs, as at very first it doesn't have any root password. is it a good idea to ...
user avatar
1 vote
0 answers
1k views

systemd: autossh service active but ssh exited with error

#/lib/systemd/system/autossh.service [Unit] Description=Auto Reverse SSH Requires=systemd-networkd-wait-online.service After=systemd-networkd-wait-online.service [Service] Type=forking ExecStart=/...
user avatar
  • 189
2 votes
2 answers
4k views

systemd-nspawn: redirect ports and keep internet

I'd like to know how to be able to: redirect ports between host and container (like for example forwarding the host 23 port to the container 22 port) be able to connect to the internet, for example ...
user avatar
  • 2,128
0 votes
0 answers
596 views

ntpd in systemd-nspawn

I'm playing with containerizing various parts of my server infrastructure and one of the services I would like to run in container is ntp daemon. I'm using systemd-nspawn (systemd 233) as a ...
user avatar
  • 301
1 vote
1 answer
1k views

systemd-nspawn: DHCP Discover cannot pass through a bridge from a container

What I have: A Gentoo host and an Ubuntu container. What I want: To connect the container to the network and to the host. What I'm doing: I've created a bridge on the host and added my NIC to it. ...
user avatar
3 votes
1 answer
3k views

systemd-nspawn: file-system permissions for a bound folder

What I have: A Gentoo host and an Ubuntu container. What I want: Mount /home from the host to the container and use it there as normal. What I'm doing: Start the container with -U --bind=/home ...
user avatar
1 vote
1 answer
434 views

systemd-nspawn inside lxc container

I've a nice chroot environment built with centos 7. I start it using systemd-nspawn. Everything works correctly in my local machine and in all the servers I've seen until now. Today I was asked to put ...
user avatar
  • 198
0 votes
1 answer
685 views

Generate ssh keys in systemd-nspawn

I wrote a couple of scripts to download, customize and prepare a Raspbian image for Raspberry Pi. Because the root file-system will be mounted in read-only I have to create the ssh keys BEFORE running ...
user avatar
  • 557
1 vote
0 answers
225 views

What is the interface to which nspawn binds by default?

I have a container created via debootstrap and it has network connectivity when started as systemd-nspawn -D thecontainerdir -b I have several network interfaces and would like it to bind to one of ...
user avatar
  • 1,268
2 votes
1 answer
2k views

Enabling networking in a systemd-nspawn container

I'm trying to setup container that has access to the internet but have been unsuccessful so far. # sudo systemd-nspawn -nb -M debian-tree # systemctl enable --now systemd-networkd systemd-resolved # ...
user avatar
  • 123
0 votes
1 answer
269 views

Firefox+noscript v.s. systemd-nspawn - ABE denial

[ABE] < LOCAL> Deny on {GET http://jessie/icons/openlogo-75.png <<< http://jessie/ - 1} SYSTEM rule: Site LOCAL Accept from LOCAL Deny i.e. pages on http://jessie ...
user avatar
  • 44.3k
1 vote
0 answers
179 views

debian unstable crash

Debian unstable, running in an nspawn container on Debian Jessie, crashed. On the host: $ sudo systemctl status systemd-nspawn@unstable-srv ● systemd-nspawn@unstable-srv.service - Container unstable-...
user avatar
  • 44.3k
0 votes
1 answer
822 views

System setup using systemd-nspawn

Can I use systemd-nspawn to setup a "chroot" install(in that case debian using debootstrap) before booting it? I.e. unattended install and setup. I need to set the keymap, hostname, maybe timezone ...
user avatar
  • 1,572
2 votes
0 answers
460 views

Can I get a DHCP address from within a container via the DHCP server the host is on?

I have a host (ubuntu xenial) running a container via systemd-nspawn (also xenial): systemd-nspawn --directory=gogs --network-macvlan=ens192 --boot ens192 is the host interface which gets its IP ...
user avatar
  • 1,268
3 votes
1 answer
4k views

systemd-nspawn container with separate IP address (network namespace) not working

Looking at the documentation for systemd-nspawn, it must have been intended to have a very user-friendly way to launch containers in a different network namespace. You use the -n option, and simply ...
user avatar
  • 44.3k
2 votes
0 answers
1k views

How to restart a systemd-nspawn container after the guest issues a reboot command?

I have systemd-nspawn containers which are enabled and start upon the boot of the host server. The problem I have is that they do not understand the reboot command issued on the guest: the container ...
user avatar
  • 1,268
2 votes
1 answer
2k views

Why does the nspawn of an ubuntu image fail?

I would like to systemd-nspawn an Ubuntu image (yakkety, the host is on yakkety as well). This used to work without problems, so I guess something changed in the last ~6 months. I created an image ...
user avatar
  • 1,268
1 vote
0 answers
395 views

How to restore correct ownership in nspawn containers after upgrade?

I upgraded from Ubuntu 16.04 to 16.10. I am running a few containers with systemd-nspawn. After the upgrade, some of the permissions in containers are not mapped correctly: root@delug:/tmp# ls /root ...
user avatar
  • 1,268
2 votes
1 answer
802 views

Minimal system-nspawn container for process tree isolation with embedded applications

Is it possible to use nspawn for a single executable? My goal is just to isolate the process tree of the application, not portability. Let's say you wrote an application in C, built for your target ...
user avatar
6 votes
2 answers
2k views

systemd-nspawn OS container is unusable because I can't set the root password

I combined the detailed instructions from the original blog post, and the more up to date instructions from the man page (using dnf instead of yum). # sudo dnf -y --releasever=24 --installroot=$HOME/...
user avatar
  • 44.3k
2 votes
1 answer
1k views

systemd-networkd .network ignored within systemd-nspawn container

I'm fiddling with systemd-nspawn containers on my RaspberryPi. So far booting works fine. I use the --network-veth and --network-bridge=br0 options and bridging did work well with a kvm virtual ...
user avatar
4 votes
1 answer
5k views

Access usb device from systemd-nspawn container

I want to access special USB device (not a simple flash drive) from inside container. I bind /dev/bus/usb inside container, lsusb lists USBs effortlessly: $ lsusb ... Bus 002 Device 002: ID 0a89:...
user avatar
  • 481
4 votes
1 answer
2k views

How to start a program in a container as a service using systemd-nspawn, systemd-run?

How do I run a listening program (specifically unoconv as a listener) inside a container using systemd-nspawn, so that it can run in the background (without a console) and be reached by other ...
user avatar