将Windows容器(使用Docker创建)部署到Azure容器服务中 [英] Deploying Windows Containers (created with Docker) into Azure Container Service

查看:111
本文介绍了将Windows容器(使用Docker创建)部署到Azure容器服务中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试完成有关如何在Azure域/环境中正确使用Windows容器的架构研究,其中我必须将Dot Net Core Web API应用程序容器化并将该容器部署到Azure容器服务中

I am trying to complete an architectural research on how to properly work with Windows Containers within the Azure domain/environment where I have to containerize the Dot Net Core Web API application and deploy that container into an Azure Container Service

这是我所做的事情

  1. 我确实在Azure门户中创建了一个Azure容器服务帐户/域/虚拟机

  1. I did create an Azure Container Service account/domain/virtual machine within the Azure portal

此外,我确实为Windows Server 2016创建了另一个虚拟机,其中已经安装了Docker的容器

Also, I did create another virtual machine for the Windows Server 2016 with Containers that already had the Docker installed

在Windows Server 2016上,我确实创建了一个简单的.NET Core Web API应用程序,并使用Docker为该应用程序创建了一个映像

On the Windows server 2016 I did create a simple .NET Core Web API application and created an image for that application using Docker

我确实将Web API应用程序的映像推送到Docker集线器中,并使用SSH隧道接口尝试将映像下载到Azure容器服务中,以便可以从该服务运行该映像

I did push the image of the Web API application into a Docker hub and using the SSH tunnel interface tried to download the image into an Azure Container Service, so it can be run from that service

但是,我会收到一条消息,提示Windows容器不能在Linux上运行,因为默认情况下Azure容器服务是Linux系统

However, I would get a message that the Windows Containers cannot run on Linux as the Azure Container Service by default is a Linux system

是否可以将Windows Docker容器部署到Azure容器服务中 一种.我应该在Windows中创建Azure容器服务吗? b.我是否应该使用其他协调器(不是Docker)将Windows容器部署到Azure容器服务中? C.我应该走另外一条路吗?

Is there a way to deploy a Windows Docker Container into an Azure Container Service a. Should I create Azure Container Service in Windows? b. Should I use another orchestrator (NOT Docker) to deploy a Windows Container into an Azure Container Service? c. Should I go down a different path?

非常感谢您的支持!

推荐答案

Windows容器不能作为Azure容器在Linux上运行 默认情况下,服务是Linux系统.

the Windows Containers cannot run on Linux as the Azure Container Service by default is a Linux system.

我们知道,关于Linux和Windows的容器是不同的,因此我们不能在Linux系统上运行Windows容器.

As we know, container about Linux and windows are different, so we can't run windows container on Linux system.

作为一种解决方法,我们可以使用Windows代理创建Azure容器服务(选择kubernetes),以便将Windows容器部署到kubernetes Windows代理.

As a workaround, we can create Azure container service(choose kubernetes) with windows agent, so we can deploy windows container to kubernetes windows agent.

我们可以通过Azure门户部署Azure容器服务,选择Orchestrator到kubernetes,在代理配置时,我们应该选择Windows操作系统.这样,kubernetes的主系统是Linux,而代理是Windows.

We can via Azure portal to deploy Azure container service, select orchestrator to kubernetes, at agent configuration, we should select operating system to windows. In this way, the master of kubernetes is Linux, and the agent is windows.

我们可以使用kubectl和docker文件创建Windows容器. 例如,我们可以在Windows代理上部署IIS容器. Kubernetes是用于管理容器的工具,因此我们可以使用k8s将IIS部署到Windows节点.

We can use kubectl and docker file to create windows container. For example, we can deploy IIS container on windows agent. Kubernetes is a tool which use to manage containers, so we can use k8s to deploy IIS to windows nodes.

1.create iis.json文件,如下所示:

1.create iis.json file, like this:

{
 "apiVersion": "v1",
 "kind": "Pod",
 "metadata": {
   "name": "iis",
   "labels": {
     "name": "iis"
   }
 },
 "spec": {
   "containers": [
     {
       "name": "iis",
       "image": "nanoserver/iis",
       "ports": [
         {
         "containerPort": 80
         }
       ]
     }
   ],
   "nodeSelector": {
    "beta.kubernetes.io/os": "windows"
    }
  }
}

2.使用kubctl apply命令创建pod,如下所示:

2.use kubctl apply command to create pods, like this:

kubectl apply -f iis.json

有关如何使用k8部署Windows IIS容器的更多信息,请参考此

More information about how to use k8s to deploy a windows IIS container, please refer to this link.

如果要使用容器映像,可以将映像上传到

If you want to use your container image, you can upload your image to Azure container registry, then pull the image from your registry.

如何为Azure容器注册表设置机密并提取图像,请参考此

How to set secret for Azure container registry and pull image, please refer to this answer.

这篇关于将Windows容器(使用Docker创建)部署到Azure容器服务中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆