buildx 无法构建多平台 docker 映像,因为它尝试复制 xattrs扩展文件属性并且无法执行此操作

问题描述

我使用 buildx 在 gitlab-ci 中构建多平台 docker 镜像。但是在构建 docker 镜像时 ci 失败了,因为它试图复制 xattrs 并且没有这样做:

> [linux/arm/v7 2/4] RUN set -xe     && apk add --no-cache ca-certificates                           ffmpeg                           openssl                           aria2                           youtube-dl:
------
Dockerfile:8
--------------------
   7 |     
   8 | >>> RUN set -xe \
   9 | >>>     && apk add --no-cache ca-certificates \
  10 | >>>                           ffmpeg \
  11 | >>>                           openssl \
  12 | >>>                           aria2 \
  13 | >>>                           youtube-dl
  14 |     
--------------------
error: Failed to solve: rpc error: code = UnkNown desc = executor Failed running [/dev/.buildkit_qemu_emulator /bin/sh -c set -xe     && apk add --no-cache ca-certificates                           ffmpeg                           openssl                           aria2                           youtube-dl]: Failed to copy xattrs: Failed to set xattr "security.selinux" on /tmp/buildkit-qemu-emulator371955051/dev/.buildkit_qemu_emulator: operation not supported

https://gitlab.com/Lukas1818/docker-youtube-dl-cron/-/jobs/1176558386#L181

我正在使用以下 ci:

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_HOST: tcp://docker:2375/

docker-build:
  # Use the docker image with buildx for multiplatform build.
  image: lukas1818/docker-with-buildx:latest
  stage: build
  services:
    - docker:dind
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  # Default branch leaves tag empty (= latest tag)
  # All other branches are tagged with the escaped branch name (commit ref slug)
  script:
    - |
      if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
        tag=""
        echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
      else
        tag=":$CI_COMMIT_REF_SLUG"
        echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
      fi
    - docker buildx create --use
    - docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag "$CI_REGISTRY_IMAGE${tag}" .
  # Run this job in a branch where a Dockerfile exists
  rules:
    - if: $CI_COMMIT_BRANCH
      exists:
        - Dockerfile

https://gitlab.com/Lukas1818/docker-youtube-dl-cron/-/blob/d12adf7779f7df71de6e9b46aa342e9ff41d5dfb/.gitlab-ci.yml

Dockerfile

#
# Dockerfile for youtube-dl
#

FROM alpine
MAINTAINER kev <noreply@easypi.pro>

RUN set -xe \
    && apk add --no-cache ca-certificates \
                          ffmpeg \
                          openssl \
                          aria2 \
                          youtube-dl

# Try to run it so we kNow it works
RUN youtube-dl --version

workdir /data

ENTRYPOINT ["youtube-dl"]
CMD ["--help"]

在我的本地机器上,使用 sudo docker buildx build --platform linux/arm/v7,linux/amd64 . 构建没有任何问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...