Docker image containing a standard Kafka distribution.
Versions used in this docker image:
Image details:
To start the Kafka Docker image:
docker run -i -t bde2020/docker-kafka /bin/bash
To build the Kafka Docker image:
git clone https://github.com/big-data-europe/docker-kafka.git
docker build -t bde2020/docker-kafka .
To start a Kafka Server inside this Docker image
cd /usr/local/apache-kafka/current
./bin/kafka-start-server.sh ./config/server.properties
cd /usr/local/apache-kafka/current
./bin/kafka-start-server.sh ./config/server.properties \
--override zookeeper.connect=192.168.88.219:2181,192.168.88.229:2181
To start Kafka Docker image on Marathon:
{
"container": {
"type": "DOCKER",
"volumes": [
{
"containerPath": "/tmp/kafka-logs",
"hostPath": "/var/lib/bde/kafka-logs",
"mode": "RW"
}
],
"docker": {
"network": "BRIDGE",
"image": "bde2020/docker-kafka",
"privileged":true,
"portMappings": [
{ "containerPort": 9092, "hostPort": 9092}
]
}
},
"id":"apache-kafka",
"cpus": 0.2,
"mem": 512,
"cmd": "cd /usr/local/apache-kafka/current && ./bin/kafka-server-start.sh ./config/server.properties --override zookeeper.connect=192.168.88.219:2181,192.168.88.220:2181,192.168.88.221:2181/kafka --override delete.topic.enable=true --override advertised.host.name=$HOST --override advertised.port=$PORT0",
"instances":1,
"ports":[9092],
"requirePorts":true,
"constraints":[["hostname","UNIQUE",""]]
}
To create a Kafka topic:
docker ps
on one of the hosts. This will expose the containerId of the running bde2020/docker-kafka container, e.g. 8b797c0d80b3.
docker exec -t -i 8b797c0d80b3 /bin/bash
Inside the docker container cd into /usr/local/apache-kafka/current. Issue the following command to see available options for topic creation.
./bin/kafka-topics.sh --help
./bin/kafka-topics.sh --create --topic sampleTopic \
--zookeeper 192.168.88.219:2181/kafka \
--partitions 3 \
--replication-factor 1
./bin/kafka-topics.sh --list --zookeeper 192.168.88.219:2181/kafka
./bin/kafka-console-producer.sh --topic sampleTopic --broker-list bigdata-one.example.com:9092
After starting the producer simply type in some messages in the console and hit enter after every single message, we will consume these messages in the next step. Hit ctrl-c to stop the producer.
./bin/kafka-console-consumer.sh --topic sampleTopic \
--zookeeper 192.168.88.219:2181/kafka \
--bootstrap-server bigdata-one.example:9092 --from-beginning
To run the Kafka Image on the BDE Platform:
To run easily integrated with the BDE Platform this image provides the possibility to startup Apache Kafka and create a Kafka topic (in case it doesn't exist) using json config files.
These json files correspond to the many options that are available from Apache Kafka and are translated to Apache Kafka shell commands on the fly.
To run the Apache Kafka image using the BDE Platform, it is necessary to extend this image, adding to json files (see below) to the /config directory.
FROM bde2020/kafka
ADD kafka-startup.json /config/
ADD kafka-init.json /config/
[
{
"sh":"/app/bin/kafka-server-start.sh",
"./config/server.properties":"",
"--override":"-Djava.net.preferIPv4Stack=true",
"--override":"zookeeper.connect=192.168.88.219:2181,192.168.88.220:2181,192.168.88.221:2181/kafka"
}
]
* The kafka-init.json (example, the options are dependent on the use case)
```json
[
{
"sh":"/app/bin/kafka-topics.sh",
"--zookeeper":"192.168.88.219:2181,192.168.88.220:2181,192.168.88.221:2181/kafka",
"--create":"",
"--topic":"sampleTopic",
"--partitions":"3",
"--replication-factor":"1"
}
]
/app/bin/kafka-init
Content type
Image
Digest
Size
491.9 MB
Last updated
over 9 years ago
docker pull harishaws/docker-kafka