Sign inSign up

mlawry/ubuntu-kafka

By mlawry

•Updated almost 8 years ago

Ubuntu 18.04 with Apache Kafka 2.0.0

Image
0

1.3K

mlawry/ubuntu-kafka repository overview

Dockerfile:

FROM ubuntu:18.04
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y openjdk-11-jre
COPY kafka_2.11-2.0.0/ /opt/kafka/
COPY start-kafka.sh /opt/kafka/
EXPOSE 2181
EXPOSE 9092
ENTRYPOINT ["/bin/bash", "/opt/kafka/start-kafka.sh"]

The kafka_2.11-2.0.0/ directory is simply the uncompressed content of kafka_2.11-2.0.0.tgz downloaded straight from Apache Download Mirror. No changes have been made to the contents.

The start-kafka.sh script looks like this:

#!/bin/bash

# Edit server.properties using values passed in via env variables.
if [ -n "$KAFKA_BROKER_ID" ]; then
  # Remove any existing entries and replace with new entry.
  sed -i '/^broker\.id.*$/d' /opt/kafka/config/server.properties
  printf "\nbroker.id=$KAFKA_BROKER_ID\n" >> /opt/kafka/config/server.properties
fi

if [ -n "$KAFKA_LISTENERS" ]; then
  # Remove any existing entries and replace with new entry.
  sed -i '/^listeners.*$/d' /opt/kafka/config/server.properties
  printf "\nlisteners=$KAFKA_LISTENERS\n" >> /opt/kafka/config/server.properties
fi

if [ -n "$KAFKA_ADVERTISED_LISTENERS" ]; then
  # Remove any existing entries and replace with new entry.
  sed -i '/^advertised\.listeners.*$/d' /opt/kafka/config/server.properties
  printf "\nadvertised.listeners=$KAFKA_ADVERTISED_LISTENERS\n" >> /opt/kafka/config/server.properties
fi

# Remove all comments from zookeeper.properties and print to console for the record.
sed -i '/^#.*$/d' /opt/kafka/config/zookeeper.properties
echo "Starting zookeeper using configuration file"
echo "-----------------------------------"
cat /opt/kafka/config/zookeeper.properties
echo "-----------------------------------"

# Start zookeeper in background, but wait 10 seconds for it to settle.
/opt/kafka/bin/zookeeper-server-start.sh /opt/kafka/config/zookeeper.properties &
sleep 10s

# Remove all comments from server.properties and print to console for the record.
sed -i '/^#.*$/d' /opt/kafka/config/server.properties
echo "Starting kafka using configuration file"
echo "-----------------------------------"
cat /opt/kafka/config/server.properties
echo "-----------------------------------"

# Start kafka in the foreground.
/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties

Tag summary

Content type

Image

Digest

Size

243.7 MB

Last updated

almost 8 years ago

docker pull mlawry/ubuntu-kafka