【问题标题】:Using BuildKit with a mounted `/var/run/docker.sock` in GitLab CI在 GitLab CI 中使用 BuildKit 和挂载的`/var/run/docker.sock`
【发布时间】:2020-11-22 15:24:29
【问题描述】:

我有一个注册的gitlab-runner 和一个docker 执行者。当它运行这个.gitlab-ci.yml:

image: docker:latest

variables:
  DOCKER_BUILDKIT: "1" 

build:
  stage: build
  script:
    # There are additional flags cut out requiring BuildKit.
    - docker build . 

并安装了/var/run/docker.sock,但失败并显示:

ERROR: docker.io/docker/dockerfile:experimental not found
------
 > resolve image config for docker.io/docker/dockerfile:experimental:
------
failed to solve with frontend dockerfile.v0: failed to solve with frontend gateway.v0: docker.io/docker/dockerfile:experimental not found

当我包括

services:
  - docker:dind

.gitlab-ci.yml 并删除/var/run/docker.sock 挂载(因此将守护进程更改为子容器而不是主机),它成功了。

这里是Dockerfile

# syntax=docker/dockerfile:experimental
...

是否与 BuildKit / 实验语法和使用主机的 docker 套接字不兼容?我让它通过dind 使用自己的套接字与子容器一起工作,但我希望通过安装套接字来成功。

【问题讨论】:

    标签: docker dockerfile gitlab-ci docker-in-docker docker-buildkit


    【解决方案1】:

    我可以通过遵循BuildKit mode fails to fetch the frontend image when registry-mirrors is specified 的解决方案来完成这项工作。问题是我的gitlab-runner 没有注册表镜像,但是在执行作业之前执行以下操作就可以了:

    docker pull docker/dockerfile:experimental 
    
    # Replace with whatever image `Dockerfile` is based on.
    docker pull ubuntu:latest 
    

    仍然不知道为什么这个问题与registry-mirrors 相关并且由相同的东西解决,但现在这可以解决问题。

    【讨论】:

      猜你喜欢
      • 2017-08-09
      • 2019-08-14
      • 2017-08-13
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      • 2018-06-28
      • 1970-01-01
      • 2021-12-06
      相关资源
      最近更新 更多