I didn't find a question like this. I have a bash script (running in Debian) that start a systemd-nspawn
session. After that I would like to continue my script as I am in the spawned machine:
#!/bin/bash
systemd-nspawn -q --bind /usr/bin/qemu-arm-static -D /mnt/project /bin/bash
apt-get update
apt-get -y upgrade
After executing the systemd-nspawn
command, the script is suspended and the prompt of the console is inside the spawned system. When I exit the script resumes but in the LOCAL machine.
Best Answer
A couple alternatives how you can approach your problem:
Make a script you execute inside systemd-nspawn container and place the commands you wish to run there (
systemd-nspwan -D .. /your-script
). If you want to get interactive shell after running your commands, place something likeexec bash -i
at the end of script .If you want to keep your current script, you could provide your commands as input to bash:
This works fine if you don't require an interactive shell afterwards.