简体   繁体   English

AKS 中的 Docker-in-Docker

[英]Docker-in-Docker in AKS

We have been tasked with setting up a container-based Jenkins deployment, and there is strong pressure to do this in AKS.我们的任务是设置基于容器的 Jenkins 部署,而在 AKS 中执行此操作的压力很大。 Our Jenkins needs to be able to build other containers.我们的 Jenkins 需要能够构建其他容器。 Normally I'd handle this with a docker-in-docker approach by mounting /var/run/docker.sock & /usr/bin/docker into my running container.通常我会通过将 /var/run/docker.sock 和 /usr/bin/docker 安装到我正在运行的容器中来使用 docker-in-docker 方法来处理这个问题。

I do not know if this is possible in AKS or not.我不知道这在 AKS 中是否可行。 Some forum posts on GitHub suggest that host-mounting is possible but broken in the latest AKS relase. GitHub 上的一些论坛帖子表明可以安装主机,但在最新的 AKS 版本中已损坏。 My limited experimentation with a Helm chart was met with this error:我对 Helm 图表的有限实验遇到了这个错误:

Error: release jenkins4 failed: Deployment.apps "jenkins" is invalid:
[spec.template.spec.initContainers[0].volumeMounts[0].name: Required 
value, spec.template.spec.initContainers[0].volumeMounts[0].name: Not 
found: ""]

The change I made was to update the volumeMounts: section of jenkins-master-deployment.yaml and include the following:我所做的更改是更新 jenkins-master-deployment.yaml 的volumeMounts:部分,并包含以下内容:

  -
  type: HostPath
  hostPath: /var/run/docker.sock
  mountPath: /var/run/docker.sock

Is what I'm trying to do even possible based on AKS security settings, or did I just mess up my chart?基于 AKS 安全设置,我正在尝试做的事情是否可行,还是我只是搞砸了我的图表?

If it's not possible to mount the docker socket into a container in AKS, that's fine, I just need a definitive answer.如果无法将 docker 套接字安装到 AKS 中的容器中,那很好,我只需要一个明确的答案。

Thanks,谢谢,

Well, we did this a while back for VSTS (cloud TFS, now called Azure DevOps) build agents, so it should be possible.好吧,我们不久前为 VSTS(云 TFS,现在称为 Azure DevOps)构建代理做了这个,所以它应该是可能的。 The way we did it is also with mounting the docker.sock我们这样做的方法也是安装 docker.sock

The relevant part for us was:对我们来说相关的部分是:

    ... container spec ...
    volumeMounts:
    - mountPath: /var/run/docker.sock
      name: docker-volume
  volumes:
  - name: docker-volume
    hostPath:
      path: /var/run/docker.sock

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM