[lxc-devel] SIMPLE C PROGRAM IN LXC CONTAINER

Peter Fedorow pfedorow at hcn-inc.com
Fri Nov 21 20:01:04 UTC 2014


When I last tried to do this a few months ago, (with a 32-bit LXC on a 
64-bit host,) you required some files inside of the container.

I populated the lxc with the following script:
---
echo "    Copy files into lxc container."
cp --verbose tmp/init.lxc lxctarget/usr/sbin/ 2>&1
cp --verbose --no-dereference tmp/liblxc.so.1* 
lxctarget/usr/lib/i386-linux-gnu/
cp --verbose --no-dereference tmp/libapparmor.so.1* 
lxctarget/usr/lib/i386-linux-gnu/
cp --verbose --no-dereference tmp/libseccomp.so.2* 
lxctarget/usr/lib/i386-linux-gnu/
cp --verbose --no-dereference tmp/libcgmanager.so.0* 
lxctarget/lib/i386-linux-gnu/

echo "    Set permissions."
chown root:root lxctarget/usr/sbin/init.lxc
chown root:root lxctarget/usr/lib/i386-linux-gnu/liblxc.so.*
chown root:root lxctarget/usr/lib/i386-linux-gnu/libapparmor.so.1*
chown root:root lxctarget/usr/lib/i386-linux-gnu/libseccomp.so.2*
chown root:root lxctarget/lib/i386-linux-gnu/libcgmanager.so.0*
---
The need for init.lxc may have been fixed.


Statically link your C program.

Use lxc-execute to run the program.


Regards,
Peter Fedorow


On 14-11-21 01:28 PM, beproject criu wrote:
> How do i create a container running only a simple c program,say the
> container has only a c program running in it,where the c program has an
> infinite loop in it.
> Please help,
>
> Thanks.
>
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
>

-- 
Manager, Information & Technology Systems
The Hotel Communication Network Inc.
Office: 1-613-216-1495 x6235
Mobile: 1-613-216-1495 x6230
www.hcn-inc.com


More information about the lxc-devel mailing list