- Author: Jeff McCune <email@example.com>
- Company: Puppet Labs
- Github ID: jeffmccune
- Pull Request 630 Discussion
- Pull Request 630 File Diff
Without this patch the virtual and is_virtual facts are returning "physical" and "false" respectively. This is a problem because Linux Containers are a virtual environment and it is useful to configure things differently in lxc when compared to other virtual environments.
This patch addresses the problem by detecting if the process is running inside of a linux container by looking at the cgroup entries for the init process. This method is described at http://stackoverflow.com/questions/20010199/determining-if-a-process-runs-inside-lxc-docker#
Basically, if /proc/1/cgroup looks like this, we're not in a lxc container:
But if they look like this then we are in a container:
The identifier is the container id and might be useful for a future fact to identify the container Facter is running in.