docker composer service accessible in nested image

Viewed 31

I first created a docker file to install both kafka and kafka s3 connector:

FROM bitnami/kafka:2.4.1
LABEL description="This images install bitnami kafka2.4.1 and kafka s3 sink connector 10.1.0"
USER root

# general container environment
ENV JAVA_HOME=/opt/bitnami/java/
ENV PWD=/opt/bitnami/kafka/bin
ENV PATH= /opt/bitnami/java/bin:/opt/bitnami/common/bin:/opt/bitnami/kafka/bin:/opt/bitnami/common/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# kafka environment properties
ENV  KAFKA_BROKER_ID=1
ENV KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
ENV KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
**ENV KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181**
ENV ALLOW_PLAINTEXT_LISTENER=yes
ENV KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=100

# kafka s3 sink connector environment properties
ENV CONNECT_GROUP_ID=kafka-connect
ENV CONNECT_CONFIG_STORAGE_TOPIC=_kafka-connect-configs
ENV CONNECT_OFFSET_STORAGE_TOPIC=_kafka-connect-offsets
ENV CONNECT_STATUS_STORAGE_TOPIC=_kafka-connect-status
ENV CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR="1"
ENV CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR="1"
ENV CONNECT_STATUS_STORAGE_REPLICATION_FACTOR="1"
ENV CONNECT_PLUGIN_PATH='/plugins/,/usr/share/java,/usr/share/confluent-hub-components/,/connectors/'

# preparation for install
#   Installing bash tools: top ping wget vi and ps
RUN apt-get update -y && apt-get install -y procps && apt-get install -y iputils-ping && apt-get install -y wget && \
                         apt-get install -y vim  && apt-get install -y procps && apt-get install -y netcat
#   download and install connector
RUN mkdir -p /plugins/lib

# download and install kafka s3 connector zip
RUN cd /plugins && \
    wget https://api.hub.confluent.io/api/plugins/confluentinc/kafka-connect-s3/versions/10.1.0/archive && \
    unzip ./archive && \
    cp -f confluentinc-kafka-connect-s3-10.1.0/lib/* /plugins/lib/

# install s3 connector properties files
COPY ./connector.properties /plugins/.
COPY ./s3-sink.properties /plugins/.
WORKDIR /opt/bitnami/kafka/bin

Please note the line ENV KAFKA_CFG_ZOOKEEPER_CONNECT zookeeper:2181 zookeeper is a service name that I will later define in a docker-composer.yml file

I created a docker composer yml file which looks like this:

version: "2"
services:
  zookeeper:
    image: 'bitnami/zookeeper:latest'
    ports:
      - 2181:2181
    environment:
      - ALLOW_ANONYMOUS_LOGIN=yes

  kafka-s3-connector:
    image: 'bitnami.kafka.and.s3connector:2.4.1'
    user: root
    ports:
      - 9092:9092
    environment:
     ...

And finally when I run docker-compose up -d two containers are started: zookeeper and kafka+connector

However if I log into the kafka+connector container, I found that kafka is not started. The reason is /opt/bitnami/kafka/config/server.properties contains wrong zookeeper.connect=localhost:2181. The bitnami/kafka:2.4.1 image contains an ENTRYPOINT that will execute entrypoint.sh script to modify server.properties based on env var. it seems like this step is skipped.

Is there any way to force the original bitnami/kafka:2.4.1 image to be loaded as is without anything skipped?

0 Answers
Related