[Lxc-users] File sharing between host and container during startup
Daniel Lezcano
daniel.lezcano at free.fr
Tue Jun 8 08:49:22 UTC 2010
On 06/07/2010 08:39 PM, Nirmal Guhan wrote:
>> AFAICS, you would like to share the filesystem, maybe you not need to
>> specify a rootfs.
>>
>> I suggest you remove the containers you previously created in order to
>> restart on a sane base. In case, list them with "lxc-ls" to make sure you
>> have no remaining containers set on your system.
>>
>> Then just do without any previous creation:
>>
>> lxc-execute -n foo<myapplication>
>>
>> Your application will run with its own private mount points, pids, ipcs,
>> uts and setup with a cgroup.
>>
>> If you need more isolation like the network:
>>
>> create a configuration file "eg. lxc.conf"
>>
>> lxc.utsname = myapplication
>> lxc.network.type = veth
>> lxc.network.flags = up
>> lxc.network.link = br0
>> lxc.network.ipv4 = 1.2.3.5/24
>>
>> and launch it with the command lxc-execute -n foo -f lxc.conf
>> <myapplication>
>>
>> Or alternatively without a configuration file,
>>
>> lxc-execute -n foo -s lxc.utsname=myapplication -s lxc.network.type=veth -s
>> lxc.network.flags=up -s lxc.network.link=br0 -s lxc.network.ipv4=
>> 1.2.3.5/24<myapplication>
>>
>> At this point, if you need to be more secure or the application you are
>> launching is writing to a directory and this is conflicting with another
>> instance of the same application, let me know, I will give you a more
>> complex configuration.
>>
>> What is needed are informations about the application (a web server, a
>> sshd, an autistic application, etc ...).
>>
>> Thanks
>> -- Daniel
>>
>>
>>
> Hi Daniel,
>
> It seems to work after I removed the rootfs and fstab from the config file.
> Otherwise I get an error as below :
>
>
>
>> [root at guhan-fedora lxc]# lxc-ls
>> [root at guhan-fedora lxc]# lxc-execute -n centos -f centos.config /bin/bash
>> lxc-execute: No such file or directory - failed to exec
>> /usr/libexec/lxc-init
>> [root at guhan-fedora lxc]# lxc-create -n centos -f centos.config
>> 'centos' created
>> [root at guhan-fedora lxc]# lxc-execute -n centos /bin/bash
>> lxc-execute: No such file or directory - failed to exec
>> /usr/libexec/lxc-init
>> [root at guhan-fedora lxc]# lxc-execute -n centos -f centos.config /bin/bash
>> lxc-execute: No such file or directory - failed to exec
>> /usr/libexec/lxc-init
>> [root at guhan-fedora lxc]#
>>
>>
> Removing rootfs fixes the issue and my app runs. Does this mean, application
> container does NOT need rootfs and hence installation of the distro etc. ?
>
Usually for application containers, you don't need a rootfs, neither
installing a distro.
But if your application for example writes a file in /tmp/FILE and you
launch the another container with the same application, this second
instance will overwrite the /tmp/FILE. So you need to give a private
/tmp for the container that can be a tmpfs or a bind mounted directory
or whatever. It is up to you to study your application and give the
right configuration to the container.
> For system containers, I installed rootfs using debootstrap. I believe these
> steps are not required. Please enlighten.
>
For a system container, by essence, you don't know what will be the
application launched inside, so you need to do full isolation with a
rootfs etc ...
More information about the lxc-users
mailing list