I am trying to run an ASP.NET Core application using Docker and I would like to expose the external wwwroot folder to the container, so that when I make changes to it from the outside, they are automatically available to my app. Is this possible, using volumes?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes it is possible. If you use docker run then you should do below
docker run -v /path/on/host:/wwwroot/path/in/container <image>
If you use docker-compose
then you should add below to the service
version: "3"
services:
myapp:
build: .
volumes:
- /path/on/host:/wwwroot/path/in/container
If you are using this on Docker for Windows then you may have to some path translation like
/c/path/on/host:/wwwroot/path/in/container