我使用 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/