您的位置:首页 > 运维架构 > Docker

如何将.NET 4.0写的Windows service和Web API部署到docker上面

2018-02-27 15:11 597 查看
Web API.
看这篇文章:

https://docs.microsoft.com/en-us/aspnet/mvc/overview/deployment/docker-aspnetmvc

Windows service.
看这篇文章https://stackoverflow.com/questions/39705529/console-app-or-windows-service-in-windows-container

一个docker container就是一个service,可以把windows service改写成exe, 然后在docker container里面一直运行这个exe, container启动了就等于service启动了,container停止了就等于service停止了。

No, you don't want to install it as a service. When you run an application in a container, Docker monitors the active process in the container. If the active process stops, the container exits. So you should run your app in the foreground, and let Docker put the container in the background (by starting it with docker run -d).

An exception is where the existing platform is already a Windows Service - e.g. the microsoft/iisimage. IIS is running in the background in the container, so you need to start another process to keep the container running - which is why you see IIS containers started like this:

docker run -d -p 80:80 microsoft/iis ping -t localhost

The ping command keeps the container running, while the IIS service actually responds to requests. This is not ideal though, Docker is monitoring ping so if the IIS service stops the container keeps running.

继续看第三点如何将Exe部署到docker上面去。

Windows application.
看这篇文章: https://hub.docker.com/r/microsoft/dotnet-framework/

这里是如何在docker上部署一个.net的console application: https://docs.microsoft.com/en-us/dotnet/framework/docker/console
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: