根本原因

根本原因

我的 Dockerfile 是:

FROM python:3.9-slim-bullseye


RUN apt-get update && apt-get install \
    --no-install-recommends -qq -y \
    apt-utils \
    poppler-utils \
    libjpeg-dev \
    libcairo2-dev \
    pdftk \
    ghostscript \
    autoconf-archive \
    pkg-config \
    libpng-dev \
    libtiff5-dev \
    zlib1g-dev \
    imagemagick \
    wget \
    procps \
    curl \
    locales \
    libicu-dev \
    libpango1.0-dev \
    g++ \
    make \
    tesseract-ocr \
    tesseract-ocr-por \
    tesseract-ocr-osd

我可以在我的机器(Ubuntu 20.04 和 Docker 版本 19.03.10)上构建它sudo docker build -t foo .,但我不能在 Travis CI 上做同样的事情:

Errors were encountered while processing:
 libpaper1:amd64
 libgs9:amd64
 ghostscript
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get update && apt-get install     --no-install-recommends -qq -y     apt-utils     poppler-utils     libjpeg-dev     libcairo2-dev     pdftk     ghostscript     autoconf-archive     pkg-config     libpng-dev     libtiff5-dev     zlib1g-dev     imagemagick     wget     procps     curl     locales     libicu-dev     libpango1.0-dev     g++     make     tesseract-ocr     tesseract-ocr-por     tesseract-ocr-osd     libc6     libgs9     ucf     libpaper1' returned a non-zero code: 100

有关 libpaper1 的部分日志:

Setting up libpaper1:amd64 (1.1.28+b1) ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Creating config file /etc/papersize with new version
stat: cannot statx '/etc/papersize.dpkg-inst': Operation not permitted
dpkg: error processing package libpaper1:amd64 (--configure):
 installed libpaper1:amd64 package post-installation script subprocess returned error exit status 1

有关 libgs9 的部分日志:

dpkg: error processing package libgs9:amd64 (--configure):
 dependency problems - leaving unconfigured

有关 Ghostscript 的部分日志:

dpkg: dependency problems prevent configuration of ghostscript:
 ghostscript depends on libgs9 (= 9.53.3~dfsg-7+deb11u1); however:
  Package libgs9:amd64 is not configured yet.

我尝试了以下操作但没有成功:

RUN dpkg --configure -a && apt-get -f install

并且:

RUN apt-get clean && apt-get update && apt-get install --fix-broken

RUN apt-get install --assume-yes --no-install-recommends -qq \

我的一部分.travis.yaml

jobs:
  include:
    - stage: Build temporary docker image
      services:
        - docker
      language: minimal
      if: type = pull_request AND branch = master
      script:
        - source ci_scripts/gcloud_setup.sh
        - gcloud docker -- pull gcr.io/foo/bar
        - docker build --cache-from gcr.io/foo/bar:latest -t bar_temp .
        - docker tag bar_temp gcr.io/foo/bar
        - gcloud docker -- push gcr.io/foo/bar

我在这里错过了什么吗?我怎样才能安装这些软件包而不出错?

答案1

根本原因

简而言之libpaper1,截至今天,该软件包在 travis 上使用的默认 docker 版本的某些配置步骤上已被破坏。

安装失败的配置步骤问题libpaper1来自statxlibseccomp。 On docker在 docker 18.04 中statx被列入白名单。libseccomp

https://github.com/moby/moby/pull/36417

然而,仅凭这一点并不能完全解释问题,截至今天docker --version,travis 状态18.06.0-ce应该将 statx 列入白名单,但仍然存在我没有找到原因的问题。

不过,升级 docker 镜像版本可以解决问题。

解决方案

更改 travis 上的 docker 版本解决了修复和statx的安装问题。libpaper1ghostscript

在您的.travis.yml文件中添加以下内容:

# Need docker-ce 20 instead of docker-ce 18 for installing ghostscript/libpaper1 on debian:bullseye
# https://docs.travis-ci.com/user/docker/#installing-a-newer-docker-version
before_install:
   - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
   - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
   - sudo apt-get update
   - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce

https://docs.travis-ci.com/user/docker/#installing-a-newer-docker-version

工藤https://github.com/florentx为了找出答案

相关内容