首页 > 解决方案 > Docker alpine:edge 如何启用测试

问题描述

我想从我的 Dockerfile 中的测试存储库安装bazel

FROM alpine:edge AS env
RUN apk add --no-cache git build-base bazel
CMD [ "/bin/sh" ]

观察到的:

$ docker build --target env -t test .
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM alpine:edge AS env
 ---> 24cae4d038c0
Step 2/3 : RUN apk add --no-cache git build-base bazel
 ---> Running in 6ce08db21af0
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  bazel (missing):
    required by: world[bazel]
The command '/bin/sh -c apk add --no-cache git build-base bazel' returned a non-zero code: 1

标签: dockeralpine

解决方案


只需使用:

# Create a virtual environment with all tools installed
# ref: https://hub.docker.com/_/alpine
FROM alpine:edge AS env
RUN apk add --no-cache git build-base
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing bazel
CMD [ "/bin/sh" ]

推荐阅读