[lxc-users] Establish a bind mount to a running container

Jäkel, Guido G.Jaekel at dnb.de
Fri Oct 7 13:26:26 UTC 2016


>-----Original Message-----
>From: lxc-users [mailto:lxc-users-bounces at lists.linuxcontainers.org] On Behalf Of Stéphane Graber
>Sent: Friday, October 07, 2016 11:46 AM
>To: LXC users mailing-list
>Subject: Re: [lxc-users] Establish a bind mount to a running container
>
>On Fri, Oct 07, 2016 at 07:03:21AM +0000, Jäkel, Guido wrote:
>> Dear experts,
>>
>> I wonder if it's possible to establish a bind mount filesystem resource from the LXC host to an already running container in
>an manual way, but analogous as it is done at startup time.
>>
>> I already figured out that the releasing an existing link is no thing; just umount it from inside the container. But is there a
>way to establish one while shifting the destination of a bind mount into the right namespace?
>>
>> I ask about, because in a couple of days I have to change a (NFS) filesystem source (because of an hardware migration)
>that is common to a large number of running containers but not frequently used and I want to avoid to restart all the
>containers with it services.
>>
>> thank you for advice
>>
>> Guido
>
>It's very difficult due to a number of restrictions in place in the kernel.
>
>The only way of doing this that I'm aware of is what we do in LXD. We
>create a path on the host before the container starts, put that on a
>rshared mountpoint, then bind-mount that directory into the container
>under some arbitrary path.
>
>Then when you want to inject a new mount in the container, you can mount
>it in a sub-directory of that path you create on the host, which will
>then have the container inherit the mount entry thanks to the host
>mountpoint being rshared and the container's mountpoint being rslave.
>
>Once the mountpoint shows up in the container, you can then move it to
>whatever path you actually want it on.


Dear Stéphane,

I sorry, but I don't get it yet; some of your terms and where to do it are dubious to me. Maybe an example may light it up to me:

Let say, I want to inject the path  host:/mnt/some_host_mountpoint/some_directory  as a bind mount to a running container; it should end up on  container:/import/some_container_moutpoint  . On the host, the mountpoint host:/mnt/some_host_mountpoint is mouted to a NFS source, let say  nfshost:/some_export

Now please, where to issue which commands?




More information about the lxc-users mailing list