运行 Azure 容器实例 (ACI) 中的 Gitlab Runner

Running Gitlab Runner in Azure Container Instances (ACI)

我想 运行 Azure 容器实例 (ACI) 中的 Gitlab-Runner。

为此,我在 Azure ACI 中有 docker 容器 gitlab/gitlab-runner 运行ning。

使用以下命令,我为我的 Gitlab 服务器注册了这个 运行ner。

gitlab-runner register \
  --non-interactive \
  --run-untagged=true \
  --locked=false \
  --executor "docker" \
  --docker-image docker:latest  \
  --url "https://gitlab.com/" \
  --registration-token "MyTokenYYYYYYYY" \
  --description "my-own-runner" \
  --tag-list "frontend, runner" \
  --docker-volumes /var/run/docker.sock:/var/run/docker.sock

新的运行ner在gitlab下也被认可了。但是,当我 运行 一份工作时,出现以下错误。

Preparing the "docker" executor
ERROR: Failed to remove network for build
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (docker.go:960:0s)

如果我 运行 在笔记本电脑上本地配置相同的 Runner,一切正常。我如何让它在 Azure ACI 中工作?

如何在注册时将 docker sock 安装到 Azure ACI 中?

非常感谢您的帮助。

您将无法在您在 Azure ACI 中创建的容器中 运行 另一个 docker 容器。为了实现“docker-in-docker”(dind),守护程序实例(在这种情况下是您的 ACI 容器)需要在特权模式下 运行ning,这将允许升级访问您与其他 ACI 用户共享的主机。您可以 read about this more on Docker hub 上面写着:

Note: --privileged is required for Docker-in-Docker to function properly, but it should be used with care as it provides full access to the host environment, as explained in the relevant section of the Docker documentation.

常见的解决方案是使用一个由 0 个或更多 VM 组成的自动缩放组来为你的 gitlab 运行ners 和他们产生的容器提供计算资源。