我可以在Docker容器中运行IIS上托管的dotnet应用程序吗?

编程入门 行业动态 更新时间:2024-10-25 05:24:20
本文介绍了我可以在Docker容器中运行IIS上托管的dotnet应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经使用asp dotnet开发了一个Web应用程序,目前我已经在IIS上运行它了,无论如何我都可以在docker容器中运行相同的应用程序,

I have developed a web application using asp dotnet and currently I have it running on IIS is there anyway I can run the same app in a docker container,

I对Docker来说还比较陌生,我玩了一段时间,并且对docker compose很熟悉,所以我想知道是否可以(dockerize)我开发的应用程序。

I am relatively new to Docker and I have played around a bit and I am familiar with docker compose , so I was wondering if I can (dockerize) the application that I have developed.

我的Dockerfile现在看起来像:

My Dockerfile now looks like:

#Making a dotnet container FROM microsoft/dotnet:latest #Make a directory WORKDIR /app #copy dll files and other dependencies COPY . /app #dotnet run should run the app ENTRYPOINT ["DOTNET","RUN"]

据我了解,这将在dotnet容器中建立一个目录,并将文件复制到当前文件夹中,该应用程序将在dotnet run上运行

From what I understand this makes a directory inside my dotnet container and copies the files in the current folder and the app will run on dotnet run

推荐答案

您需要更改一些Dockerfile,请尝试以下操作:

You need to change a little your Dockerfile, try this:

#Making a dotnet container FROM microsoft/iis SHELL ["powershell"] RUN Install-WindowsFeature NET-Framework-45-ASPNET ; \ Install-WindowsFeature Web-Asp-Net45 RUN Remove-WebSite -Name 'Default Web Site' RUN New-Website -Name 'app' -Port 80 \ -PhysicalPath 'c:\app' -ApplicationPool '.NET v4.5' #copy dll files and other dependencies COPY app app #dotnet run should run the app CMD ["ping", "-t", "localhost"]

测试

docker build -t app . docker run --name app -d -p 80:80 app docker inspect --format="{{.NetworkSettings.Networks.nat.IPAddress}}" app

它将为您提供一个ip,只需在浏览器中对其进行测试即可。

It will give you an ip just test it in your browser.

详细信息:在IIS + ASP.NET上运行Windows 10和Docker

更多推荐

我可以在Docker容器中运行IIS上托管的dotnet应用程序吗?

本文发布于:2023-11-17 05:27:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608989.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   应用程序   Docker   dotnet   IIS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!