I have /var/lib/home
folder in my docker container and I want to access this folder contents from my computer.
How to map this folder to host?
I'd like this folder to be writable also during usage.
I have /var/lib/home
folder in my docker container and I want to access this folder contents from my computer.
How to map this folder to host?
I'd like this folder to be writable also during usage.
You can make use of bind mounts
When you use a bind mount, a file or directory on the host machine is mounted into a container. The file or directory is referenced by its full or relative path on the host machine. By contrast, when you use a volume, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.
docker run -d \
-it \
--name bind--mount-test \
--mount type=bind,source=/path/to/host/directory/,target=/var/lib/home \
<docker image name>
bear in mind the first time when the container is created, /var/lib/home will be mounted from the host and not vice-versa