[英]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.