본문 바로가기

개발로그/Error Collection

docker kakfa 빌드 실패

docker kakfa 빌드 실패

wurstmeister/kafka-docker 이미지로 Docker Kafka 환경을 구성하려고 가이드대로 명령어 실행했으나 에러 발생

docker-compose -f docker-compose-single-broker.yml up -d

대충 레포지토리에 접근하지 못하는 것 같았고 원인은 로컬의 인증서인듯 함

폐쇄망 환경에서 사설인증서를 쓰고 Mac OS가 신뢰하도록 사용 중이었는데 bash로 실행시엔 적용이 안되어서?

아래는 오류 메시지 전체

$ docker-compose up -d
Building kafka
Step 1/14 : FROM azul/zulu-openjdk-alpine:8u292-8.54.0.21
 ---> ef8cf3e3bc92
Step 2/14 : ARG kafka_version=2.8.1
 ---> Using cache
 ---> e83872bf5fd8
Step 3/14 : ARG scala_version=2.13
 ---> Using cache
 ---> 2e5bcaec9d6e
Step 4/14 : ARG glibc_version=2.31-r0
 ---> Using cache
 ---> e8614d481f32
Step 5/14 : ARG vcs_ref=unspecified
 ---> Using cache
 ---> d45a294c4b88
Step 6/14 : ARG build_date=unspecified
 ---> Using cache
 ---> 824ba551dde2
Step 7/14 : LABEL org.label-schema.name="kafka"       org.label-schema.description="Apache Kafka"       org.label-schema.build-date="${build_date}"       org.label-schema.vcs-url="https://github.com/wurstmeister/kafka-docker"       org.label-schema.vcs-ref="${vcs_ref}"       org.label-schema.version="${scala_version}_${kafka_version}"       org.label-schema.schema-version="1.0"       maintainer="wurstmeister"
 ---> Using cache
 ---> 7f35154ea715
Step 8/14 : ENV KAFKA_VERSION=$kafka_version     SCALA_VERSION=$scala_version     KAFKA_HOME=/opt/kafka     GLIBC_VERSION=$glibc_version
 ---> Using cache
 ---> 24499c47d231
Step 9/14 : ENV PATH=${PATH}:${KAFKA_HOME}/bin
 ---> Using cache
 ---> d46e17807de4
Step 10/14 : COPY download-kafka.sh start-kafka.sh broker-list.sh create-topics.sh versions.sh /tmp/
 ---> 46dff1f68f13
Step 11/14 : RUN apk add --no-cache bash curl jq docker  && chmod a+x /tmp/*.sh  && mv /tmp/start-kafka.sh /tmp/broker-list.sh /tmp/create-topics.sh /tmp/versions.sh /usr/bin  && sync && /tmp/download-kafka.sh  && tar xfz /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C /opt  && rm /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz  && ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} ${KAFKA_HOME}  && rm /tmp/*  && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk  && apk add --no-cache --allow-untrusted glibc-${GLIBC_VERSION}.apk  && rm glibc-${GLIBC_VERSION}.apk
 ---> Running in 20d0974f85ce
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/x86_64/APKINDEX.tar.gz
139645780663112:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:
fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/x86_64/APKINDEX.tar.gz
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: Permission denied
139645780663112:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: Permission denied
fetch https://repos.azul.com/zulu/alpine/x86_64/APKINDEX.tar.gz
139645780663112:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1913:
WARNING: Ignoring https://repos.azul.com/zulu/alpine: Permission denied
ERROR: unable to select packages:
  bash (no such package):
    required by: world[bash]
  curl (no such package):
    required by: world[curl]
  docker (no such package):
    required by: world[docker]
  jq (no such package):
    required by: world[jq]
ERROR: Service 'kafka' failed to build: The command '/bin/sh -c apk add --no-cache bash curl jq docker  && chmod a+x /tmp/*.sh  && mv /tmp/start-kafka.sh /tmp/broker-list.sh /tmp/create-topics.sh /tmp/versions.sh /usr/bin  && sync && /tmp/download-kafka.sh  && tar xfz /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C /opt  && rm /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz  && ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} ${KAFKA_HOME}  && rm /tmp/*  && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk  && apk add --no-cache --allow-untrusted glibc-${GLIBC_VERSION}.apk  && rm glibc-${GLIBC_VERSION}.apk' returned a non-zero code: 4

해결방법

  1. repositories 파일 생성
  2. http://dl-cdn.alpinelinux.org/alpine/v3.13/main http://dl-cdn.alpinelinux.org/alpine/v3.13/community
  1. Dockerfile 에서 RUN 실행 전에 레포지토리 변경
  2. COPY repositories /etc/apk/repositories

Dockerfile

FROM azul/zulu-openjdk-alpine:8u292-8.54.0.21

ARG kafka_version=2.8.1
ARG scala_version=2.13
ARG glibc_version=2.31-r0
ARG vcs_ref=unspecified
ARG build_date=unspecified

LABEL org.label-schema.name="kafka" \
      org.label-schema.description="Apache Kafka" \
      org.label-schema.build-date="${build_date}" \
      org.label-schema.vcs-url="https://github.com/wurstmeister/kafka-docker" \
      org.label-schema.vcs-ref="${vcs_ref}" \
      org.label-schema.version="${scala_version}_${kafka_version}" \
      org.label-schema.schema-version="1.0" \
      maintainer="wurstmeister"

ENV KAFKA_VERSION=$kafka_version \
    SCALA_VERSION=$scala_version \
    KAFKA_HOME=/opt/kafka \
    GLIBC_VERSION=$glibc_version

ENV PATH=${PATH}:${KAFKA_HOME}/bin

COPY download-kafka.sh start-kafka.sh broker-list.sh create-topics.sh versions.sh /tmp/
COPY repositories /etc/apk/repositories

RUN apk add --no-cache bash curl jq docker \
 && chmod a+x /tmp/*.sh \
 && mv /tmp/start-kafka.sh /tmp/broker-list.sh /tmp/create-topics.sh /tmp/versions.sh /usr/bin \
 && sync && /tmp/download-kafka.sh \
 && tar xfz /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz -C /opt \
 && rm /tmp/kafka_${SCALA_VERSION}-${KAFKA_VERSION}.tgz \
 && ln -s /opt/kafka_${SCALA_VERSION}-${KAFKA_VERSION} ${KAFKA_HOME} \
 && rm /tmp/* \
 && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
 && apk add --no-cache --allow-untrusted glibc-${GLIBC_VERSION}.apk \
 && rm glibc-${GLIBC_VERSION}.apk

COPY overrides /opt/overrides

VOLUME ["/kafka"]

# Use "exec" form so that it runs as PID 1 (useful for graceful shutdown)
CMD ["start-kafka.sh"]

참고 : https://stackoverflow.com/questions/66201209/docker-build-using-ca-trust-bundle-from-host