Share Dir between container and host
To Mount files/dir from container to host, it need a named volume. Named volume is bind to a path of the host. If the path doesnt’s contain any files, copy from container will happends. Otherwise host file will be merged to container.
cp
command won’t override the different files of the destination dir.
Three different types of docker volume
A host volume lives on the Docker host’s filesystem and can be accessed from within the container. To create a host volume:
docker run -v /path/on/host:/path/in/container ...
An anonymous volume is useful for when you would rather have Docker handle where the files are stored. It can be difficult, however, to refer to the same volume over time when it is an anonymous volumes. To create an anonymous volume:
docker run -v /path/in/container ...
A named volume is similar to an anonymous volume. Docker manages where on disk the volume is created, but you give it a volume name. To create a named volume:
docker volume create somevolumename
docker run -v name:/path/in/container ...
NOTE: Only named volume will trigger the copy from the container to host