如何在Docker容器中运行的IIS上的Web应用程序中添加子目录?

发布于 2025-02-09 07:30:24 字数 1630 浏览 0 评论 0原文

我有一个包含2个项目的解决方案,其中1个是我的WCF Web服务,1是在ASP.NET MVC 4上制作的前端网页。我决定将这2个项目容器化,以便我可以使用CI进行API测试。

但是我很难像本地安装的IIS中的子目录一样进行子目录。这是我通常在没有Docker的本地机器上部署构建的地方:

“在此处输入映像”

由于我是这样部署的,每个应用程序都具有这样的子级别,例如

​使用Docker,我想复制此设置。我尝试在我的dockerfile上添加workdir/inetpub/wwwroot/formulabuilder,而formulabuilder则是子目录,但它不起作用。我会收到此错误:

”在此处输入图像描述”

如果您在不同端口上设置两者,则我的Web服务和前端网页都可以使用。但是我想删除端口,因此当我更新项目中的服务参考时,我不必处理冲突。此外,我希望在执行API测试时尽可能接近生产设置。

是否可以使用基本图像随附的IIS添加子目录?如果是这样,您该怎么做?以下是我的docker文件:

fbsvc(WCF Web服务项目)

FROM mcr.microsoft.com/dotnet/framework/wcf:4.8
ARG source=bin/app.publish
WORKDIR /inetpub/wwwroot/
COPY ${source:-obj/Docker/publish} .
EXPOSE 80

formulabuilder(前端网页项目)

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
ARG source=bin/app.publish
WORKDIR /inetpub/wwwroot/FormulaBuilder
COPY ${source:-obj/Docker/publish} .
EXPOSE 80

docker compose

version: "3"
services:
  web-service:
    build: ./FBSVC
    container_name: "FBSVC"
    ports:
      - "5001:80"

  front-end:
    build: ./FormulaBuilder
    container_name: "FormulaBuilder"
    ports:
      - "5000:80"

我是Docker的新手我仍在探索事物。任何帮助将不胜感激。谢谢!

I have a solution containing 2 projects, 1 is my WCF web service and 1 is a front-end web page made on ASP.NET MVC 4. I decided to containerize these 2 projects so I can do API testing with CI.

But I am having trouble making a subdirectory just like the one in a locally installed IIS. This is where I normally deploy my builds on my local machine without Docker:

enter image description here

Since I am deploying this way, each applications has sub-directories like this

enter image description here

Now that I am using Docker, I wanted to replicate this setup. I have tried adding WORKDIR /inetpub/wwwroot/FormulaBuilder on my dockerfile whereas FormulaBuilder is the sub-directory, but it didn't work. I get this error instead:

enter image description here

Both my web service and the front-end web-page works if you setup both on different ports. But I wanted to remove the ports so I don't have to deal with conflicts when I'm updating Service References on my project. In addition, I wanted to be as close to the production setup as possible when performing API testing.

Is it possible to add sub-directories with the use of IIS that came with the base image? If so, how do you do it? Below are my docker files:

FBSVC (WCF web service project)

FROM mcr.microsoft.com/dotnet/framework/wcf:4.8
ARG source=bin/app.publish
WORKDIR /inetpub/wwwroot/
COPY ${source:-obj/Docker/publish} .
EXPOSE 80

FormulaBuilder (Front-end web page project)

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8
ARG source=bin/app.publish
WORKDIR /inetpub/wwwroot/FormulaBuilder
COPY ${source:-obj/Docker/publish} .
EXPOSE 80

Docker Compose

version: "3"
services:
  web-service:
    build: ./FBSVC
    container_name: "FBSVC"
    ports:
      - "5001:80"

  front-end:
    build: ./FormulaBuilder
    container_name: "FormulaBuilder"
    ports:
      - "5000:80"

I am new to Docker and I am still exploring things. Any help would be appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文