【问题标题】:Build Singularity container using GitLab CI使用 GitLab CI 构建 Singularity 容器
【发布时间】:2020-11-26 03:49:34
【问题描述】:

我想在 GitLab CI 中构建一个奇点图像。不幸的是,official containers 失败了:

Running with gitlab-runner 13.5.0 (ece86343) on gitlab-ci d6913e69
Preparing the "docker" executor
Using Docker executor with image quay.io/singularity/singularity:v3.7.0 ...
Pulling docker image quay.io/singularity/singularity:v3.7.0 ...
Using docker image sha256:46d3827bfb2f5088e2960dd7103986adf90f2e5b4cbea9eeb0b0eacfe10e3420 for quay.io/singularity/singularity:v3.7.0 with digest quay.io/singularity/singularity@sha256:def886335e36f47854c121be0ce0c70b2ff06d9381fe8b3d1894fee689615624 ...
Preparing environment
Running on runner-d6913e69-project-2906-concurrent-0 via <gitlab.url>...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in <repo-path>
Checking out 708cc829 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
Error: unknown command "sh" for "singularity"

刚开始,当使用这样的工作时:

build-singularity:
  image: quay.io/singularity/singularity:v3.7.0
  stage: singularity
  script:
    - build reproduction/pipeline/semrepro-singularity/semrepro-singularity.sif reproduction/pipeline/semrepro-singularity/semrepro-singularity.def
  only:
    changes:
      - reproduction/pipeline/semrepro-singularity/semrepro-singularity.def
      - reproduction/pipeline/semrepro-singularity/assets/mirrorlist
      - .gitlab/ci/build-semrepo-singularity.yml
  artifacts:
    paths:
      - reproduction/pipeline/semrepro-singularity/semrepro-singularity.sif
    expire_in: 1 hour
  interruptible: true

对我来说,GitLab 似乎在尝试使用不存在的 shell?他们应该如何工作?在official example 中,他们使用了一个名为-gitlab 的特殊版本的docker 镜像,但不幸的是它不再可用了。有任何想法吗?我无法想象在 CI 中构建奇点容器是不可能的?提前非常感谢!

编辑:根据@tsnowlan 的回答,覆盖入口点可以解决上述问题。但是,现在构建失败了:

singularity build semrepro-singularity.sif semrepro-singularity.def
INFO:    Starting build...
INFO:    Downloading library image
84.1MiB / 84.1MiB [========================================] 100 % 28.7 MiB/s 0s
ERROR:   unpackSIF failed: root filesystem extraction failed: extract command failed: ERROR  : Failed to create user namespace: not allowed to create user namespace: exit status 1
FATAL:   While performing build: packer failed to pack: root filesystem extraction failed: extract command failed: ERROR  : Failed to create user namespace: not allowed to create user namespace: exit status 1
Cleaning up file based variables
ERROR: Job failed: exit code 1

有什么想法吗?

【问题讨论】:

    标签: docker continuous-integration gitlab-ci virtualization singularity-container


    【解决方案1】:

    您需要对其进行一些修改以使其与 gitlab CI 配合使用。我发现的最简单的方法是破坏 docker 入口点,并让脚本步骤成为完整的奇异性构建命令。我们正在使用它来使用 v3.6.4 构建我们的奇点图像,但它也应该适用于 v3.7.0。

    例如,

    build-singularity:
      image: 
        name: quay.io/singularity/singularity:v3.7.0
        entrypoint: [""]
      stage: singularity
      script:
        - singularity build reproduction/pipeline/semrepro-singularity/semrepro-singularity.sif reproduction/pipeline/semrepro-singularity/semrepro-singularity.def
      ...
    

    edit: 使用的 gitlab-runner 还必须启用 privileged。这是gitlab.com shared runners 上的默认设置,但如果使用您自己的跑步者,您需要确保在他们的配置中进行了设置。

    【讨论】:

    • 非常感谢!实际上,这解决了构建甚至无法开始的初始问题!但是,它遇到了我之前在尝试自制 docker 映像时遇到的另一个问题。我认为这可能是我的自定义 docker 问题的问题,但显然不是。构建失败并显示 ERROR: unpackSIF failed: root filesystem extraction failed: extract command failed: ERROR : Failed to create user namespace: not allowed to create user namespace。有什么想法吗?
    • 我忘记了 sudo。使用它,它应该可以工作
    • 等等,它应该以 root 身份运行。这很奇怪
    • 啊哈,是的,我想就是这样。我们运行我们自己的 gitlab-runners,它们使用--privileged 运行。虽然看起来共享跑步者也应该是:docs.gitlab.com/13.6/ee/user/gitlab_com/…
    • 啊,如果您在托管实例上运行,那么在他们在运行器上启用特权模式之前,您将不走运。对于 docker-in-docker 或奇异性在 docker 来说,这是一个硬性要求
    猜你喜欢
    • 1970-01-01
    • 2017-05-15
    • 1970-01-01
    • 2018-07-24
    • 2014-09-16
    • 1970-01-01
    • 2015-10-07
    • 2021-12-29
    • 2023-03-16
    相关资源
    最近更新 更多