First of all thanks for the great product! I am really enjoying exploring Docker.
Here is my first post. If something is wrong in posting, please guide me. So my question is;
Is it possible to mount container top level folder to a folder on host?
like this;
docker run -it -v /root/any/folder:/ --name test1 ubuntu:16.04
I tried it but failed. Is there any way to do that?
If you could successfully run docker run -v /host/path:/ image then it would cause the contents of /host/path to be the only thing visible in the container; it would be the container’s root. That is, you can mount things into the container but not out.
My recommendation would be to use docker run -v sparingly – maybe only for /var/log and any persistent data your application requires – but if you don’t mind manually managing paths and aren’t using a multi-host setup then using explicit host paths for these are fine.
Just out of curiosity: what sense does it make to create a container and replace it’s entire filesystem (image layers + copy-on-write container layer) with a bind-mount from a host folder?
It would not make sense usually but I think the original goal was to make the container’s filesystem available in a specific directory on the host.
which is not what bind mount is for. Other goal could be creating an empty image without filesystem (from scratch), starting a container and mounting the filesystem from the host. I did something similar in my latest tutorial but I mounted a file not the root filesystem.