Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab pipeline Docker build gets stuck on apk

Trying to make a simple GitLab pipeline that builds a Docker image for Alpine Linux + Openshift CLI.

This is the code:

FROM frolvlad/alpine-glibc:latest

MAINTAINER Daniel Widerin <[email protected]>

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"]

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 <[email protected]>
 ---> 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.

Tried this same Dockerfile manually and it works fine.

How can I diagnose this issue? How can I find any logs for this?

like image 315
robliv Avatar asked Dec 27 '19 16:12

robliv


1 Answers

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 .

Related GitHub issue: github.com/gliderlabs/docker-alpine/issues/307

like image 152
robliv Avatar answered Sep 30 '22 13:09

robliv