projectatomic / docker

Docker - the open-source application container engine
http://www.docker.com
Apache License 2.0
81 stars 58 forks source link

volume: allow a prefix for all bind mounts #302

Closed giuseppe closed 6 years ago

giuseppe commented 6 years ago

volume: allow a prefix for all bind mounts

Introduce a new environment variable DOCKER_BIND_MOUNT_PREFIX that is added as a prefix to the source for every bind mount. This allows Docker to run inside of a container, and be able to see the host rootfs.

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

rhatdan commented 6 years ago

So if I am running docker in a container with /host mounted and a user on the host says

docker run -v /var/lib/mariadb:/var/lib/mariadb ...

You will get /host/var/lib/mariadb:/var/lib/mariadb mounted?

We would need something similar to this in CRI-o also. I think you should add the above explanation to your PR.

giuseppe commented 6 years ago

So if I am running docker in a container with /host mounted and a user on the host says

docker run -v /var/lib/mariadb:/var/lib/mariadb ...

You will get /host/var/lib/mariadb:/var/lib/mariadb mounted?

yes exactly. In this way we can have the same visibility as if running on the host.

I've amended the commit log message with this example.

giuseppe commented 6 years ago

does the new version look fine?

giuseppe commented 6 years ago

I've tested the PR with symlinks and they are correctly resolved with the /host prefix before the mount

rhatdan commented 6 years ago

LGTM Do we have a PR for this in CRI-O?

giuseppe commented 6 years ago

not yet, I can work on it

rhatdan commented 6 years ago

@runcom PTAL

giuseppe commented 6 years ago

The CRI-O counterpart: https://github.com/kubernetes-incubator/cri-o/pull/1485

giuseppe commented 6 years ago

anything blocking this PR?

runcom commented 6 years ago

LGTM

runcom commented 6 years ago

we need this in branch docker-1.13.1-rhel as well @giuseppe

giuseppe commented 6 years ago

@runcom backport here: https://github.com/projectatomic/docker/pull/308