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
15 views

Linux container initialization script utilizing systemd

I am trying to make a template filesystem for my systemd-nspawn container. The container filesystem will be cloned from this template by btrfs snapshot. I needs the container to run a initialization ...
Waiho's user avatar
  • 33
0 votes
0 answers
37 views

How to make a restrictive syscall *whitelist* with systemd-nspawn?

I'm trying to lock down a container using systemd-nspawn, so that only the specific syscalls I whitelist are allowed. Per the documentation, there's a pretty lax filter in place by default, ...
SwarmOfBees's user avatar
0 votes
1 answer
387 views

Failed to get login PTY: Failed to activate service 'org.freedesktop.systemd1'

Been trying to understand and play around with systemd-nspawn because I'd like to run a Debian Testing install for myself without enabling the testing repos on my main Debian stable system. I wrote ...
mrjpaxton's user avatar
0 votes
0 answers
70 views

apt-get update in systemd-nspawn does nothing

I am trying to set up a container running ubuntu 18.04 on a host running ubuntu 22.04. I am using mkosi to build my image and systemd-nspawn to run it, specifically I invoke: mkosi -r bionic systemd-...
Daniel's user avatar
  • 101
2 votes
0 answers
204 views

How do I give my container a static ip address (systemd-nspawn)

My container changes its ip address extremely often, almost every boot. I tried giving it a static ip address so my script knows how to ssh into it but nothing I did seemed to work. So I tried looking ...
Andrew Benor's user avatar
0 votes
1 answer
121 views

How can i map multiple ports in systemd-nspawn container?

I'm writing a container manager script which depends on nspawn, and the container is using a Virtual Ethernet Connection(-n opt). but it looks like that nspawn only support port mapping for single ...
Tsing Kwai's user avatar
2 votes
0 answers
145 views

How are ulimits determined for processes running in unpriviledged containers?

Recently, while I was building something in an unprivileged nspawn container (for CI), with the host system running arch linux, I repeatedly ran into an EMFILE error, from yarn, indicating that I'm ...
Graham Leach-Krouse's user avatar
0 votes
0 answers
505 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: ...
pipe_connector's user avatar
3 votes
1 answer
811 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 ...
25pwn's user avatar
  • 33
1 vote
1 answer
414 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....
nomad87's user avatar
  • 11
3 votes
1 answer
1k 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 ...
grandinero's user avatar
0 votes
1 answer
218 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 ...
user457494's user avatar
4 votes
1 answer
4k 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/...
Badr Elmers's user avatar
0 votes
0 answers
292 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-...
alex1452's user avatar
4 votes
2 answers
3k 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 ...
icebit's user avatar
  • 205
3 votes
0 answers
4k 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 (...
aaronk6's user avatar
  • 141
1 vote
2 answers
932 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 ...
Pascal's user avatar
  • 153
13 votes
1 answer
3k 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 ...
sjy's user avatar
  • 826
2 votes
1 answer
2k 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 ...
Botspot's user avatar
  • 151
1 vote
1 answer
588 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 ...
Botspot's user avatar
  • 151
0 votes
1 answer
1k 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/...
mbigras's user avatar
  • 2,928
3 votes
1 answer
274 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 ...
Mark's user avatar
  • 713
3 votes
1 answer
2k 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. ...
vivi's user avatar
  • 31
-3 votes
1 answer
649 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 ...
Tim's user avatar
  • 99k
6 votes
1 answer
2k 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 (...
humanityANDpeace's user avatar
2 votes
0 answers
43 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 ...
WoJ's user avatar
  • 1,455
8 votes
0 answers
2k 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 ...
goyozi's user avatar
  • 151
2 votes
2 answers
2k 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 ...
Martin's user avatar
  • 21
2 votes
2 answers
6k 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 ...
Evan Carroll's user avatar
2 votes
2 answers
3k 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), ...
Evan Carroll's user avatar
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/...
enthu's user avatar
  • 61
0 votes
1 answer
261 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 ...
dgfjxcv's user avatar
  • 656
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=/...
dstonek's 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 ...
tobiasBora's user avatar
  • 3,486
0 votes
0 answers
706 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 ...
GeekMagus's 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. ...
krokoziabla's user avatar
3 votes
1 answer
4k 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 ...
krokoziabla's user avatar
1 vote
1 answer
554 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 ...
Syco's user avatar
  • 198
0 votes
1 answer
810 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 ...
Mark's user avatar
  • 713
1 vote
0 answers
279 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 ...
WoJ's user avatar
  • 1,455
2 votes
2 answers
3k 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 # ...
Ava's user avatar
  • 123
0 votes
1 answer
298 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 ...
sourcejedi's user avatar
  • 48.5k
1 vote
0 answers
197 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-ns[email protected] - Container unstable-...
sourcejedi's user avatar
  • 48.5k
0 votes
1 answer
968 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 ...
rudib's user avatar
  • 1,532
2 votes
0 answers
540 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 ...
WoJ's user avatar
  • 1,455
4 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 ...
sourcejedi's user avatar
  • 48.5k
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 ...
WoJ's user avatar
  • 1,455
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 ...
WoJ's user avatar
  • 1,455
1 vote
0 answers
490 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 ...
WoJ's user avatar
  • 1,455
2 votes
1 answer
947 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 ...
RandomUser's user avatar