Hi,<div><br></div><div>Thanks all of you, I managed to make it work !</div><div>I understand there are some security concerns, and Matto, you're pointing to a very interesting detail, dropping capability is really what I want !</div>
<div>Thanks</div><div><br></div><div>--</div><div>Samuel<br><br><div class="gmail_quote">On Mon, Jul 4, 2011 at 10:16 PM, Matto Fransen <span dir="ltr"><<a href="mailto:matto@matto.nl">matto@matto.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<div class="im"><br>
On Mon, Jun 27, 2011 at 06:05:13PM +0200, Samuel Maftoul wrote:<br>
<br>
> I'm searching for a solution to have a read only rootfs inside an LXC<br>
> container.<br>
<br>
</div>I have a webserver running this way :)<br>
<div class="im"><br>
> I created a container with the busybox template, this container works.<br>
> As soon as I try to mount it read only I have this message in the logs:<br>
<br>
</div>Create a rootfs outside the container.<br>
In the config of your container you add lines like:<br>
lxc.mount.entry=/path/to/rootfs/lib /var/lib/lxc/<container>/rootfs/lib none ro,bind 0 0<br>
and so on for all the dir's you want to mount readonly<br>
<br>
Also create some system directories:<br>
# system mounts<br>
lxc.mount.entry=proc /var/lib/lxc/<container>/rootfs/proc proc none defaults 0 0<br>
lxc.mount.entry=shmfs /var/lib/lxc/<container>/rootfs/dev/shm tmpfs mode=0644 0 0<br>
lxc.mount.entry=sysfs /var/lib/lxc/<container>/rootfs/sys sysfs defaults  0 0<br>
<br>
And add the following line to the config of your container:<br>
lxc.cap.drop=sys_admin<br>
<br>
This last line prevents that one can jumo out of the readonly bind mounts from<br>
inside the container :)<br>
<br>
Cheers,<br>
<font color="#888888"><br>
Matto<br>
</font></blockquote></div><br></div>