GitLab 管道 Docker 构建卡在 apk 上 [英] GitLab pipeline Docker build gets stuck on apk
问题描述
尝试制作一个简单的 GitLab 管道,为 Alpine Linux + Openshift CLI 构建 Docker 映像.
Trying to make a simple GitLab pipeline that builds a Docker image for Alpine Linux + Openshift CLI.
这是代码:
FROM frolvlad/alpine-glibc:latest
MAINTAINER Daniel Widerin <daniel@widerin.net>
ENV OC_VERSION=v3.11.0
OC_TAG_SHA=0cbc58b
BUILD_DEPS='tar gzip'
RUN_DEPS='curl ca-certificates gettext'
RUN apk --no-cache add $BUILD_DEPS $RUN_DEPS &&
curl -sLo /tmp/oc.tar.gz https://github.com/openshift/origin/releases/download/${OC_VERSION}/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit.tar.gz &&
tar xzvf /tmp/oc.tar.gz -C /tmp/ &&
mv /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit/oc /usr/local/bin/ &&
rm -rf /tmp/oc.tar.gz /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit &&
apk del $BUILD_DEPS
CMD ["/bin/sh"]
现在由于某种原因,在运行管道时,它会卡在下载 openshift 存档的 curl
部分.
Now for some reason when running the pipeline it gets stuck on the curl
part that downloads the openshift archive.
Status: Downloaded newer image for frolvlad/alpine-glibc:latest
---> 38dd85a430e8
Step 2/5 : MAINTAINER Daniel Widerin <daniel@widerin.net>
---> Running in bdacc7e92e79
Removing intermediate container bdacc7e92e79
---> c56da0a68f7f
Step 3/5 : ENV OC_VERSION=v3.11.0 OC_TAG_SHA=0cbc58b BUILD_DEPS='tar gzip' RUN_DEPS='curl ca-certificates gettext'
---> Running in cb1e6cdb39ca
Removing intermediate container cb1e6cdb39ca
---> 727952120e67
Step 4/5 : RUN apk --no-cache add $BUILD_DEPS $RUN_DEPS && curl -sLo /tmp/oc.tar.gz https://github.com/openshift/origin/releases/download/${OC_VERSION}/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit.tar.gz && tar xzvf /tmp/oc.tar.gz -C /tmp/ && mv /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit/oc /usr/local/bin/ && rm -rf /tmp/oc.tar.gz /tmp/openshift-origin-client-tools-${OC_VERSION}-${OC_TAG_SHA}-linux-64bit && apk del $BUILD_DEPS
---> Running in ef344ef4a96b
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
这样持续一个小时,直到管道超时.
It stays like this for an hour until the pipeline times out.
手动尝试了相同的 Dockerfile,它工作正常.
Tried this same Dockerfile manually and it works fine.
如何诊断此问题?我怎样才能找到这方面的任何日志?
How can I diagnose this issue? How can I find any logs for this?
推荐答案
发现此问题与基于 Kubernetes/OpenShift 的运行器在 Docker-in-Docker 配置中运行时 Alpine 映像存在网络问题有关.将 --network host
添加到 Docker build
有助于解决此问题.
Found that this issue is related to Alpine image having networking issues when run in Docker-in-Docker configuration on Kubernetes/OpenShift based runner. Adding --network host
to Docker build
helps to fix this issue.
Docker build --network host .
相关 GitHub 问题:github.com/gliderlabs/docker-alpine/issues/307
Related GitHub issue: github.com/gliderlabs/docker-alpine/issues/307
这篇关于GitLab 管道 Docker 构建卡在 apk 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!