Add basic kafkadocker command to run kafka in docker

main
Ensar Sarajčić 2022-06-28 19:20:21 +02:00
parent 2058691eeb
commit dafe22e7b3
1 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Runs commands for kafka CLI in docker
POSITIONAL=()
NETWORK=docker_default
HOST=kafka
PORT=9092
SKIP_SERVER=0
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-n|--network)
NETWORK=$2
shift # past argument
shift # past value
;;
-h|--host)
HOST=$2
shift # past argument
shift # past value
;;
-p|--port)
PORT=$2
shift # past argument
shift # past value
;;
--no-server)
SKIP_SERVER=1
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
if [ $SKIP_SERVER -eq 0 ]; then
POSITIONAL+=("--bootstrap-server $HOST:$PORT")
fi
echo "docker run -it --rm --network $NETWORK bitnami/kafka:latest ${POSITIONAL[@]} "
docker run -it --rm --network $NETWORK bitnami/kafka:latest ${POSITIONAL[@]}