4

Quite recently I started using systemd-nspawn to set up other OS instances on my Arch box. One thing I'd like to do is detect if I'm inside a container, and if so, add the distro name (from lsb_release) to the terminal title. On Debian-based systems, the default .bashrc uses debian_chroot for a similar purpose. How do I detect if I am running inside a nspawn container?

1 Answer 1

6

systemd-detect-virt can tell you whether your system is running in a VM/container. This requires systemd-detect-virt inside your container, but the systemd documentation on minimal builds suggests that you can just build a package that only includes systemd-detect-virt.

1
  • Excellent. Since I was using Debian 8, with systemd, for the container, systemd-detect-virt is just fine.
    – muru
    Apr 7, 2015 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .