简体   繁体   English

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

[英]Can I Run a dotnet app which is hosted on IIS in a docker container?

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, 我已经开发了一个使用asp dotnet的web应用程序,目前我在IIS上运行它无论如何我可以在docker容器中运行相同的应用程序,

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. 我对Docker比较陌生,我玩过一段时间,我熟悉docker compose,所以我想知道我是否可以(dockerize)我开发的应用程序。

My Dockerfile now looks like: 我的Dockerfile现在看起来像:

#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"]

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 据我所知,这使我的dotnet容器中的目录成为一个目录并复制当前文件夹中的文件,该应用程序将在dotnet上运行

You need to change a little your Dockerfile, try this: 你需要改变一下你的Dockerfile,试试这个:

#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"]  

Test it 测试一下

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

It will give you an ip just test it in your browser. 它会给你一个ip,只需在你的浏览器中测试它。

More information: Run IIS + ASP.NET on Windows 10 with Docker 更多信息: 使用Docker在Windows 10上运行IIS + ASP.NET

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法运行 docker IIS windows 容器 - Unable to run docker IIS windows container 在 docker 容器中运行 dotnet watch 会破坏 Nuget package 参考 - Running dotnet watch run in docker container breaks Nuget package references 如何在 docker 容器中运行 selenium chrome 驱动程序? - How can I run selenium chrome driver in a docker container? 我可以进一步减少对由docker容器上的asp.net Web API应用程序运行的docker映像的依赖性 - Can I further reduce dependency on docker images to run by asp.net web api application on docker container 我可以在将要在IIS6上托管的应用程序上使用&lt;%:标记吗? - Can I use the <%: tag on an application that will be hosted on IIS6? 杀死dotnet进程时杀死docker容器 - killing docker container when killing dotnet process 一种应用程序,用于获取托管在远程服务器中的网站的IIS和应用程序池详细信息 - An Application which fetches IIS and App Pool details of website hosted in remote server ASP.NET 6 应用程序在 WebApplication.Run 之后有很长的延迟,当托管在 IIS - ASP.NET 6 app has a long delay after WebApplication.Run when hosted in IIS 如何配置iis,以便可以从远程Windows pc连接到iis托管的localhost - how to configure iis so that I can connect to my iis hosted localhost from a remote windows pc 如何设置Web应用程序连接,以便我可以在IIS Express和Auzure云中本地运行它们 - How to setup web app connection so that I can run them locally in IIS express and in the Auzure cloud
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM