gpt4 book ai didi

docker - 在 gitlab ci before_script 中使用 apt 时找不到 apt

转载 作者:行者123 更新时间:2023-12-01 00:14:01 29 4
gpt4 key购买 nike

我使用 gitlab ci 来构建 docker 镜像,我想安装 python。当我构建时,以下是我的 gitlab-ci.yml:

image: docker:stable
stages:
- test
- build

before-script:
- apt install -y python-dev python pip

test1:
stage: test
script:
...
- pytest

build:
stage: build
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG

但我的工作失败了
/bin/sh: eval: line : apt: not found
ERROR: Job failed: exit code 127

我也试过 apt-get install 但结果是一样的。

我如何安装python?

最佳答案

这实际上不是问题,但您可以说它由带有 Alpine 的包管理器提供,您正在使用图像:docker:stable 或任何诸如 tomcat 或 Django 之类的图像,它们在 Alpine Linux 上。尺寸最小。

image: docker:stable
stages:
- test
- build

before-script:
- apk add python python-dev python pip

test1:
stage: test
script:
...
- pytest

build:
stage: build
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG

apk 是 Alpine Linux 包管理

关于docker - 在 gitlab ci before_script 中使用 apt 时找不到 apt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54996813/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com