ASP.NET Core + Docker +公开wwwroot [英] ASP.NET Core + Docker + Expose wwwroot

查看:86
本文介绍了ASP.NET Core + Docker +公开wwwroot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Docker运行ASP.NET Core应用程序,我想将外部wwwroot文件夹公开给容器,以便当我从外部对其进行更改时,它们可自动用于我的应用程序.使用卷可以吗?

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?

推荐答案

是可以的.如果您使用docker run,则应执行以下操作

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>

如果使用docker-compose,则应将以下内容添加到服务中

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

如果您正在Windows的Docker上使用它,则可能需要进行一些路径转换,例如

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

这篇关于ASP.NET Core + Docker +公开wwwroot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆