You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide capability of mount propagation between host and container #207
Currently container / is marked RPRIVATE. That means once the container starts, any mount on host is not visible in container and vice-a-versa.
People have been looking for capabilities where these restrictions can be relaxed and some kind of mount propagation can take place after container has started. There are two primary use cases.
A mount is done on host and that mount becomes visible in container.
A container does a mount and that mount becomes visible in host.
Define new rootfsPropagation modes where user can opt in for new propagation mode.
In container slave mode, one can bind mount a directory from host into container and destination mount in container will become a "slave", if source mount is "shared". Now if anything is mounted
on host in source directory, it will become visible in container too.
One can find source mount of a directory using "df " command. And one can find propagation properties of a mount using "findmnt -o TARGET,PROPAGATION " command.
Example:
Say, one wants to mount /root/mnt-source directory inside container at /root/mnt-dest. Do following.
Prepare source directory. Make sure source mount of directory is "shared". One can simply convert
source directory into a mount point and make it shared. That way one does not have to rely on
existing settings of source mount point of directory.
$ mkdir /root/mnt-source
$ mount --bind /root/mnt-source /root/mnt-source
$ mount --make-shared /root/mnt-source
Edit config.json to launch container in "container_slave" mode.
In container_shared mode, one can bind mount a directory from host into container and destination mount in container will become "shared", if source mount is "shared" and it is not source mount of container rootfs. Now if anything is mounted on host in source directory, it will become visible in container too. And if anything is mounted in container under "shared" mount, it will become visible on host.
One can find source mount of a directory using "df " command. And one can find propagation properties of a mount using "findmnt -o TARGET,PROPAGATION " command.
Example:
Say, one wants to mount /root/mnt-source directory inside container at /root/mnt-dest. Do following.
Prepare source directory. Make sure source mount of directory is "shared". One can simply convert
source directory into a mount point and make it shared. That way one does not have to rely on
existing settings of source mount point of directory.
$ mkdir /root/mnt-source
$ mount --bind /root/mnt-source /root/mnt-source
$ mount --make-shared /root/mnt-source
Edit config.json to launch container in "container_shared" mode.
Activity
rhvgoyal commentedon Aug 17, 2015
@mrunalp CC
rhvgoyal commentedon Aug 17, 2015
@rhatdan CC
rhvgoyal commentedon Aug 17, 2015
@rootfs CC
rootfs commentedon Aug 17, 2015
Docker PR can be found at moby/moby#15648
rhvgoyal commentedon Aug 18, 2015
In container slave mode, one can bind mount a directory from host into container and destination mount in container will become a "slave", if source mount is "shared". Now if anything is mounted
on host in source directory, it will become visible in container too.
One can find source mount of a directory using "df " command. And one can find propagation properties of a mount using "findmnt -o TARGET,PROPAGATION " command.
Example:
Say, one wants to mount /root/mnt-source directory inside container at /root/mnt-dest. Do following.
Prepare source directory. Make sure source mount of directory is "shared". One can simply convert
source directory into a mount point and make it shared. That way one does not have to rely on
existing settings of source mount point of directory.
$ mkdir /root/mnt-source
$ mount --bind /root/mnt-source /root/mnt-source
$ mount --make-shared /root/mnt-source
Edit config.json to launch container in "container_slave" mode.
"linux": {
...
...
"rootfsPropagation": "container_slave"
}
Edit config.json to mount /root/mnt-source in container.
{
"type": "bind",
"source": "/root/mnt-source",
"destination": "/root/mnt-dest",
"options": "rbind"
}
$ runc
$ findmnt -o TARGET,PROPAGATION /root/mnt-dest
$ mkdir /root/mnt-source/mnt1
$ mount --bind /root/mnt-source/mnt1 /root/mnt-source/mnt1
rhvgoyal commentedon Aug 18, 2015
In container_shared mode, one can bind mount a directory from host into container and destination mount in container will become "shared", if source mount is "shared" and it is not source mount of container rootfs. Now if anything is mounted on host in source directory, it will become visible in container too. And if anything is mounted in container under "shared" mount, it will become visible on host.
One can find source mount of a directory using "df " command. And one can find propagation properties of a mount using "findmnt -o TARGET,PROPAGATION " command.
Example:
Say, one wants to mount /root/mnt-source directory inside container at /root/mnt-dest. Do following.
source directory into a mount point and make it shared. That way one does not have to rely on
existing settings of source mount point of directory.
$ mkdir /root/mnt-source
$ mount --bind /root/mnt-source /root/mnt-source
$ mount --make-shared /root/mnt-source
"linux": {
...
...
"rootfsPropagation": "container_shared"
}
{
"type": "bind",
"source": "/root/mnt-source",
"destination": "/root/mnt-dest",
"options": "rbind"
}
$ runc
$ findmnt -o TARGET,PROPAGATION /root/mnt-dest
$ mkdir /root/mnt-dest/mnt1
$ mount --bind /root/mnt-dest/mnt1 /root/mnt-dest/mnt1
crosbymichael commentedon Feb 10, 2016
This was merged and is working now