Docker安裝kafka高階方式

2021-10-23 22:57:34 字數 848 閱讀 4170

你在使用docker安裝kafka的時候,是不是先啟動zookeeper,再啟動kafka,複雜的命令自己都不知道啥意思,接下來介紹一種結合docker-compose檔案的簡潔方式,雖然多了docker-compose檔案,但是命令比之前簡潔多了:

具體命令如下:

docker-compose.yml檔案:

version: 'v1.0.1'

services:

zoo1:

image: defaultzookeeper

restart: unless-stopped

hostname: zoo1

ports:

- "2181:2181"

container_name: zookeeper

# kafka version: 1.1.0

# scala version: 2.12

kafka1:

image: defaultkafa

ports:

- "9092:9092"

environment:

kafka_advertised_host_name: localhost

kafka_zookeeper_connect: "zoo1:2181"

kafka_broker_id: 1

kafka_offsets_topic_replication_factor: 1

kafka_create_topics: "stream-in:1:1,stream-out:1:1"

depends_on:

- zoo1

container_name: kafka1

Docker容器安裝kafka

docker run d name zookeeper p 2181 2181 t wurstmeister zookeeperdocker run d name kafka p 9092 9092 e kafka broker id 0 e kafka zookeeper connect 192....

docker 安裝kafka 快速

docker pull wurstmeister zookeeper docker pull wurstmeister kafka 啟動映象 docker run d name zookeeper publish 2181 2181 volume etc localtime etc localtim...

docker容器下安裝kafka例項

docker 環境的安裝可以參考 docker簡介和linux下安裝 進入正題 docker pull wurstmeister zookeeper啟動執行zookeeper映象的例項 docker run d name zookeeper 01 p 2181 2181 t wurstmeister...