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

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

本文介绍了我可以在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.

详细信息:

这篇关于我可以在Docker容器中运行IIS上托管的dotnet应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:16