I create a web server container with some default static resources. I'd like to use nginx to proxy the static files, and the Nginx service in the host, so I need to access the static files in container from the host, I try to set the --volume
when run the container as below:
docker run -d
--name=some-server
-p 8080:8080
-v /var/myserver/data:/app/static
some-server-image
and the host directory /var/myserver/data
is a empty directory, and I found the host's directory covers the container's directory.
Is there any way to access the container's data from host? or any other solutions. Thanks a lot!
PS: I have to manage the static files with the git version control, so some solutions like manage static files use other third party service, not suit for me.
Take a look here . I think the problem is with your notation, you should be specifyng a source volume , as opposed to a source directory .
Try with:
docker run -d
--name=some-server
-p 8080:8080
-v my_nginx_new_volume:/app/static
some-server-image
This should create a new volume, populated with the data from your container's /app/static
directory.
Even better would be to use --mount
notation instead of -v
notation
docker run -d \
--name=nginxtest \
--mount source=my_nginx_new_volume,destination=/app/static \
-p 8080:8080 \
some-server-image
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.