ASP.NET Core + Docker + Expose wwwroot

2019-06-08 11:49发布

问题:

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