基于 debian 的 docker 构建镜像在从基于 CI/CD alpine 的 dind 镜像构建时找不到 apt

问题描述 投票:0回答:1

所以我已经在本地构建我的图像一段时间了,没有任何问题:

FROM python:3.12-slim
RUN apt update
{...}

现在我想自动部署此映像,因此我将 gitlab-ci.yml 设置为以下内容:

image: docker:latest

services:
  - docker:dind
stages:
  - test
  - build
  - deploy

before_script:
  - apk add bash ncurses docker-compose
  - apk add --no-cache openssh-client bash
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY

{...}

build-controller-image:
  tags:
    - linux_docker_privileged
  stage: build
  script:
    - version=$(bash ./scripts/script_get_version.sh "processing" "docker_versions.txt")
    - docker build -t processing:$version --platform linux/arm64 processing
  when: manual

{...}

作业启动并拉取 python 映像,但失败:

[ 2/19] RUN apt update
0.440 exec /bin/sh: no such file or directory
ERROR: executor failed running [/bin/sh -c apt update]: exit code: 1

python 映像是基于 debian 的,因此进行 apt 更新应该没有问题。我对 dind 有什么不正确的做法吗?

我尝试在本地提取具有相同哈希值的图像,看看是否可以从我的 ci/cd 中重现该问题,但运气不佳。一切仍然在本地构建

docker continuous-integration alpine-linux debian-based docker-in-docker
1个回答
0
投票

这是一个与系统架构与容器架构相关的问题。使用 buildx 允许我构建镜像,而不管使用什么机器。请参阅:https://docs.docker.com/build/architecture/了解更多详细信息

© www.soinside.com 2019 - 2024. All rights reserved.