<div dir="ltr">It looks like something being executed is expecting your rootfs to be writeable, this could be something in lxc-execute or it could be /bin/bash itself (I wouldn't know without strace'ing both or looking at the source).<div>
<br></div><div>You could try adding the necessary /dev, /proc and /sys mounts, which may be enough to get it to run without error (add the following into your lxc config);</div><div><a href="http://pastebin.com/ZAcXn926">http://pastebin.com/ZAcXn926</a><br>
</div><div><br></div><div>However any applications expecting a write-able FS are going to fail hard - for example, anything relying on /tmp, or /var/log, and numerous other places. You could in theory bind mount a ramfs to those locations, but it would be easier, in my opinion, to use a stacked file system.</div>
<div><br></div><div>Here is an example of using overlayfs;</div><div><a href="http://askubuntu.com/questions/109413/how-do-i-use-overlayfs">http://askubuntu.com/questions/109413/how-do-i-use-overlayfs</a><br></div><div><br>
</div><div>In short, you'd build your container rootfs and make whatever changes you wanted to make, once you're happy with it you then do;</div><br>$ mount -t overlayfs -o lowerdir=/your.rootfs.here,upperdir=/your.discarded.changes.here overlayfs /your.new.mount.here<div>
lxc.rootfs = /your.new.mount.here</div><div><br></div><div>There is also a previous discussion on this;</div><div><a href="http://osdir.com/ml/lxc-chroot-linux-containers/2011-07/msg00019.html">http://osdir.com/ml/lxc-chroot-linux-containers/2011-07/msg00019.html</a><br>
</div><div><a href="https://www.redhat.com/archives/libvirt-users/2011-December/msg00024.html">https://www.redhat.com/archives/libvirt-users/2011-December/msg00024.html</a><br></div><div><a href="http://s3hh.wordpress.com/2011/09/22/sharing-mounts-with-a-container/">http://s3hh.wordpress.com/2011/09/22/sharing-mounts-with-a-container/</a><br>
</div><div><a href="https://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg02190.html">https://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg02190.html</a><br></div><div><br></div><div>Hope this helps</div>
<div><br>Cal</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 19, 2013 at 1:51 AM, Antonin Bas <span dir="ltr"><<a href="mailto:antoninb@stanford.edu" target="_blank">antoninb@stanford.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I guess that could do it. But I don't understand while it would not be<br>
possible to have a read-only rootfs (i.e. is what I am seeing the<br>
expected behaviour?).<br>
What would the configuration look like if I decided to use overlayfs?<br>
Is it easy to use with lxc-execute? Because I just want to run an<br>
application, and I don't want to pay the overhead of<br>
lxc-start-ephemeral.<br>
<br>
Thanks,<br>
<br>
Antonin<br>
<br>
2013/12/18 Cal Leeming [Simplicity Media Ltd]<br>
<<a href="mailto:cal.leeming@simplicitymedialtd.co.uk">cal.leeming@simplicitymedialtd.co.uk</a>>:<br>
<div class="HOEnZb"><div class="h5">> Would it not be better to use a stacked file system, such as overlayfs or<br>
> aufs, then discard the changes?<br>
><br>
> Cal<br>
><br>
><br>
> On Thu, Dec 19, 2013 at 12:49 AM, Antonin Bas <<a href="mailto:antoninb@stanford.edu">antoninb@stanford.edu</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> I am trying to run an application container with lxc-execute. I am<br>
>> going to run "untrusted" student codes in this container and I want<br>
>> the root file system to be shared with the host but read-only. I<br>
>> thought this would be as easy as using the following configuration<br>
>> file:<br>
>><br>
>> # Container with new network withtout network devices<br>
>> lxc.utsname = omega<br>
>> lxc.network.type = empty<br>
>> lxc.network.flags = up<br>
>><br>
>> lxc.rootfs = /tmp/guest/rootfs<br>
>> lxc.mount.entry=/ /tmp/guest/rootfs/ none ro,bind 0 0<br>
>><br>
>> However, when I run `sudo lxc-execute -n test -f grader.conf<br>
>> --logpriority=DEBUG -- /bin/bash`, I get the following message:<br>
>><br>
>> lxc-execute: Read-only file system - error unlinking<br>
>> /usr/lib/x86_64-linux-gnu/lxc/dev/kmsg<br>
>><br>
>> lxc-execute: failed to setup kmsg for 'test'<br>
>> lxc-execute: Read-only file system - failed to create directory<br>
>> '/usr/lib/x86_64-linux-gnu/lxc/lxc_putold'<br>
>><br>
>> lxc-execute: Read-only file system - failed to create pivotdir<br>
>> '/usr/lib/x86_64-linux-gnu/lxc/lxc_putold'<br>
>> lxc-execute: failed to setup pivot root<br>
>> lxc-execute: failed to set rootfs for 'test'<br>
>> lxc-execute: failed to setup the container<br>
>> lxc-execute: invalid sequence number 1. expected 2<br>
>> lxc-execute: failed to spawn 'test'<br>
>><br>
>><br>
>> Is it possible to have some insight on what the problem is here?<br>
>> I am using Ubuntu 13.10, and my lxc is the one from the official repo<br>
>> (1.0.0.alpha1).<br>
>><br>
>> Thanks you in advance for your help,<br>
>><br>
>> Antonin<br>
>> _______________________________________________<br>
>> lxc-users mailing list<br>
>> <a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.linuxcontainers.org</a><br>
>> <a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> lxc-users mailing list<br>
> <a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.linuxcontainers.org</a><br>
> <a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br>
_______________________________________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br>
</div></div></blockquote></div><br></div>