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

本文介绍了如何将Windows服务和.NET应用程序部署到Docker容器中。包括将Windows服务转换为可执行文件并在容器中持续运行的方法,以及部署.NET控制台应用程序的具体步骤。
  1. Web API.

    看这篇文章:

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

  2. 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上面去。

  1. Windows application.

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

  2. 这里是如何在docker上部署一个.net的console application: https://docs.microsoft.com/en-us/dotnet/framework/docker/console 

转载于:https://www.cnblogs.com/time-is-life/p/8479027.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值