3 ms·
It depends on the init system, however. systemd makes an effort to ensure that running /sbin/init inside of a container works and can be detected by the softwa
by philips 13y ago
It depends on the init system, however.
systemd makes an effort to ensure that running /sbin/init inside of a container works and can be detected by the software and services underneath it[1]. In general this means that if you take a copy of Arch or Fedora and try to run it inside of a container it works properly without any hacks.
For your own services you can also start to do the right things by using the virtualization detection code[2] that is built in. The most immediately useful one being: ConditionVirtualization=container and !container. With these directives you can tell your services to run or not run depending on whether you are in a container or on real hardware.
[1]: http://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/ http://www.freedesktop.org/wiki/Software/systemd/ContainerIn...
[2] http://www.freedesktop.org/software/systemd/man/systemd.unit.html#ConditionPathExists= http://www.freedesktop.org/software/systemd/man/systemd.unit...
- mst 13y agoConditionVirtualization=container seems like a "with great power comes great ability to screw up in subtle and horrible ways" sort of feature, wherein when you need it, you really need it, but most of the time, a different approach will be vastly preferable.
- philips 13y agoAbsolutely. This was in the context of the parent talking about doing things without certain privileges or skipping unnecessary steps.
- makomk 13y agoSame with Gentoo's homebrew init system OpenRC, which has had support for running in various kinds of containers for a while now.