<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 14 July 2015 at 22:33, Tycho Andersen <span dir="ltr"><<a href="mailto:tycho.andersen@canonical.com" target="_blank">tycho.andersen@canonical.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Mon, Jul 13, 2015 at 10:53:10AM +0200, Christoph Mathys wrote:<br>
> Is there an unhacky way of knowing if a script runs inside a<br>
> container? In my case, a sysV initscript that tries to load some<br>
> kernel modules needs to know if it runs inside the container, because<br>
> it must not load the modules in that case.<br>
><br>
> The hacky way I came across so far was checking the control group of PID 1.<br>
><br>
> Checking /proc/1/environ is considered OK? Or are there better ways?<br>
<br>
root@precise:/# cat /var/run/container_type<br>
lxc<br>
<br>
may be a better option for you.<br></blockquote><div><br></div><div>/etc/init/container-detect.conf creates that file.<br></div><div><br></div><div>It seems that it gets that "lxc" string from environment variable "container", but I can not find ATM how/where that is set and how it is determined what to set. Maybe I am totally wrong and it may very well be some upstart construct.</div><div><br></div><div>Does anyone know where that container variable gets its value from?</div><div><br></div><div>b.</div><div><br></div></div></div></div>