我想在docker单一映像中将kafka rest代理与kafka一起安装。我们正在使用kafka映像作为基础映像,并希望在其顶部安装kafka-rest-proxy。下面提到的是我们的Docker文件
We have taken this as reference while creating this file
https://github.com/confluentinc/kafka-rest-images/blob/master/kafka-rest/Dockerfile.deb8
FROM confluentinc/cp-kafka:5.5.0
ARG PROJECT_VERSION
ARG ARTIFACT_ID
ARG CONFLUENT_VERSION
ARG CONFLUENT_PACKAGES_REPO
ARG CONFLUENT_PLATFORM_LABEL
ARG CONFLUENT_DEB_VERSION
ARG ALLOW_UNSIGNED
LABEL io.confluent.docker.git.repo="confluentinc/kafka-rest-images"
ENV COMPONENT=kafka-rest
ENV KAFKA_REST_ZOOKEEPER_CONNECT=myzookeeper-zk:2181
ENV KAFKA_REST_HOST_NAME=test-kafka
# default listener
EXPOSE 8082
RUN echo "===> Installing ${COMPONENT}..." \
&& apt-get update \
&& echo "===> Adding confluent repository...https://packages.confluent.io/deb/5.5" \
&& if [ "x$ALLOW_UNSIGNED" = "xtrue" ]; then echo "APT::Get::AllowUnauthenticated \"true\";" > /etc/apt/apt.conf.d/allow_unauthenticated; else curl -s -L https://packages.confluent.io/deb/5.5/archive.key -o /tmp/archive.key && apt-key add /tmp/archive.key; fi \
&& echo "deb [arch=amd64] https://packages.confluent.io/deb/5.5 stable main" >> /etc/apt/sources.list \
&& sed -i 's;http://archive.debian.org/debian/;http://deb.debian.org/debian/;' /etc/apt/sources.list \
&& cat /etc/apt/sources.list \
&& apt-get install -y apt-transport-https \
&& apt-get install -y apt-utils \
&& apt-get update \
&& apt-get install -y confluent-${COMPONENT}=${CONFLUENT_VERSION}${CONFLUENT_PLATFORM_LABEL}-${CONFLUENT_DEB_VERSION} \
confluent-control-center=${CONFLUENT_VERSION}${CONFLUENT_PLATFORM_LABEL}-${CONFLUENT_DEB_VERSION} \
confluent-security=${CONFLUENT_VERSION}${CONFLUENT_PLATFORM_LABEL}-${CONFLUENT_DEB_VERSION} \
&& echo "===> clean up ..." \
&& apt-get clean && rm -rf /tmp/* /var/lib/apt/lists/* \
&& echo "===> Setting up ${COMPONENT} dirs" \
&& chmod -R ag+w /etc/${COMPONENT}
COPY include/etc/confluent/docker /etc/confluent/docker
CMD ["/etc/confluent/docker/run"]
图像已成功构建
docker build . -t my-kafka-rest-custom:3.3.3
Sending build context to Docker daemon 358.4kB
Step 1/21 : FROM confluentinc/cp-kafka:5.0.1
---> 5467234daea9
Step 2/21 : ARG PROJECT_VERSION
---> Using cache
---> bf90e3020232
Step 3/21 : ARG ARTIFACT_ID
---> Using cache
---> 3306ca86672a
Step 4/21 : ARG CONFLUENT_VERSION
---> Using cache
---> 09f037fa5954
Step 5/21 : ARG CONFLUENT_PACKAGES_REPO
---> Using cache
---> 6760a594ee94
Step 6/21 : ARG CONFLUENT_PLATFORM_LABEL
---> Using cache
---> d1321ff49c72
Step 7/21 : ARG CONFLUENT_DEB_VERSION
---> Using cache
---> 2cdb2b914f65
Step 8/21 : ARG ALLOW_UNSIGNED
---> Using cache
---> 8ba2b344ed5e
Step 9/21 : LABEL io.confluent.docker.git.repo="confluentinc/kafka-rest-images"
---> Using cache
---> a07481842889
Step 10/21 : ENV COMPONENT=kafka-rest
---> Using cache
---> 3ac4051385f1
.
.
.
.
.
.
Step 15/21 : ENV KAFKA_REST_ZOOKEEPER_CONNECT=myzookeeper-zk
---> Using cache
---> 470e38dda0d1
Step 16/21 : ENV KAFKA_REST_HOST_NAME=test-kafka
---> Using cache
---> faf0fc54ded6
Step 17/21 : EXPOSE 8082
---> Using cache
---> bd28c9c8e539
Step 18/21 : RUN echo "===> Installing ${COMPONENT}..." && apt-get update && echo "===> Adding confluent repository...https://packages.confluent.io/deb/5.5" && if [ "x$ALLOW_UNSIGNED" = "xtrue" ]; then echo "APT::Get::AllowUnauthenticated \"true\";" > /etc/apt/apt.conf.d/allow_unauthenticated; else curl -s -L https://packages.confluent.io/deb/5.5/archive.key -o /tmp/archive.key && apt-key add /tmp/archive.key; fi && echo "deb [arch=amd64] https://packages.confluent.io/deb/5.5 stable main" >> /etc/apt/sources.list && sed -i 's;http://archive.debian.org/debian/;http://deb.debian.org/debian/;' /etc/apt/sources.list && cat /etc/apt/sources.list && apt-get install -y apt-transport-https && apt-get install -y apt-utils && apt-get update && apt-get install -y confluent-${COMPONENT}=${CONFLUENT_VERSION}${CONFLUENT_PLATFORM_LABEL}-${CONFLUENT_DEB_VERSION} confluent-control-center=${CONFLUENT_VERSION}${CONFLUENT_PLATFORM_LABEL}-${CONFLUENT_DEB_VERSION} confluent-security=${CONFLUENT_VERSION}${CONFLUENT_PLATFORM_LABEL}-${CONFLUENT_DEB_VERSION} && echo "===> clean up ..." && apt-get clean && rm -rf /tmp/* /var/lib/apt/lists/* && echo "===> Setting up ${COMPONENT} dirs" && chmod -R ag+w /etc/${COMPONENT}
---> Using cache
---> 4d311cc7cf93
Step 19/21 : COPY include/etc/confluent/docker /etc/confluent/docker
---> Using cache
---> 579bd961c0d8
.
.
Step 21/21 : CMD ["/etc/confluent/docker/run"]
---> Running in 4e7051ffde90
Removing intermediate container 4e7051ffde90
---> 61376569c763
Successfully built 61376569c763
Successfully tagged my-kafka-rest-custom:3.3.3
[当我尝试使用Openshift上的头盔图安装它时,成功提取了图像并创建了容器,但是它一次又一次地重新启动,并且在一段时间后崩溃了。在检查日志时,我们在日志中遇到以下错误
main-SendThread(myzookeeper-zk:2181)] INFO org.apache.zookeeper.ClientCnxn - Socket connection established, initiating session, client: /10.130.27.9:45270, server: myzookeeper-zk/10.128.105.218:2181
[main-SendThread(myzookeeper-zk:2181)] INFO org.apache.zookeeper.ClientCnxn - Session establishment complete on server myzookeeper-zk/10.128.105.218:2181, sessionid = 0x20039cfaa970059, negotiated timeout = 40000
[main] INFO org.apache.zookeeper.ZooKeeper - Session: 0x20039cfaa970059 closed
[main] ERROR io.confluent.admin.utils.cli.KafkaReadyCommand - Error while running kafka-ready.
[main-EventThread] INFO org.apache.zookeeper.ClientCnxn - EventThread shut down for session: 0x20039cfaa970059
org.apache.kafka.common.errors.TimeoutException: Timed out waiting for Kafka to register brokers in Zookeeper. timeout (ms) = 40000
通过覆盖组件变量,代理将不再启动。
其余代理需要经纪人