expose files from docker container to host
Volumes are treated as mounts in Docker, which means the host directory will always be mounted over the container's directory. In other words, what you're trying to do isn't currently possible with Docker volumes.
See this Github issue for a discussion on this subject: https://github.com/docker/docker/issues/4361
One possible work-around would be to have a docker volume to an empty directory in your container, and then in your Docker RUN command (or start-up script), copy the static contents into that empty directory that is mounted as a volume.
Reading from: Dockers Volume Page
Volumes have several advantages over bind mounts:
New volumes can have their content pre-populated by a container.
Similar example using docker-compose
Using nginx's default webpage folder as the example:
$ docker volume create xmpl
$ docker run -v xmpl:/usr/share/nginx/html nginx
Will yield all the files on the host system via:
$ docker inspect xmpl
...
"Mountpoint": "/var/lib/docker/volumes/xmpl/_data"
And you can then view the files on the host:
# ls /var/lib/docker/volumes/xmpl/_data
50x.html index.html
And finally to use it from /var/nginx/static:
# mkdir -p /var/nginx
# ln -s /var/lib/docker/volumes/xmpl/_data /var/nginx/static
# ls /var/nginx/static
50x.html index.html
Another nice solution: 1. Install SSHd 2. Install SSHFS on Host 3. Mount folder inside docker container to outside (host) by SSHFS