In my Debian development machine I set up a systemd-nspawn environment for customizing an embedded systemd.
I'm able to send command to this container from a script, in this way:
systemd-nspawn -q --bind /usr/bin/qemu-arm-static -D $MOUNTPATH /bin/bash << EOF
apt-get update
apt-get -y upgrade
EOF
Now I need to do the same but starting the container with the -b (boot) flag. Is still possible to do that inside a script?
Right now I do the following manually:
- start systemd-nspawn with -b flag
- login
- issue the commands
- halt
is just same with
/bin/init is a example here, may be any init system (like /usr/lib/systemd/systemd).
it's auto detected.
If you use
--boot, then you lose control of the first program in container.Init system will run your program. But you must follow the instructions of your init system. create init.rc script or systemd service.
and another "tricky way" is: