wurstmeister/zookeeper 是什么
时间: 2024-05-17 12:11:53 浏览: 47
wurstmeister/zookeeper 是一个 Docker 镜像,用于在 Docker 容器中运行 Apache ZooKeeper。Apache ZooKeeper 是一个分布式应用程序的协调服务,它可以管理和协调大型分布式系统中的节点。wurstmeister/zookeeper 镜像提供了一个简单的方式来在 Docker 容器中运行 ZooKeeper 服务,使得开发人员可以在本地环境中轻松地进行分布式应用程序的开发和测试。
相关问题
docker run -it --name zookeeper -p 12181:2181 -d wurstmeister/zookeeper:latest 根据这条命令帮我写个docker-compose
Sure! Here's the equivalent `docker-compose.yml` file for the given Docker command:
```yaml
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- 12181:2181
container_name: zookeeper
tty: true
restart: always
```
You can save this content into a file named `docker-compose.yml` and run `docker-compose up -d` to start the ZooKeeper container.
version: '3' services: zookeeper: image: wurstmeister/zookeeper:latest ports: - 12181:2181 container_name: zookeeper tty: true restart: alwaysversion: '3' services: kafka01: image: wurstmeister/kafka:latest ports: - 19092:9092 environment: - KAFKA_BROKER_ID=0 - KAFKA_ZOOKEEPER_CONNECT=192.168.233.129:12181 - KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.233.129:19092 - KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 container_name: kafka01 tty: true restart: always 这两天帮我整合在一起
Certainly! Here's the combined `docker-compose.yml` file for both ZooKeeper and Kafka:
```yaml
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- 12181:2181
container_name: zookeeper
tty: true
restart: always
kafka01:
image: wurstmeister/kafka:latest
ports:
- 19092:9092
environment:
- KAFKA_BROKER_ID=0
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka01:19092
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092
container_name: kafka01
depends_on:
- zookeeper
tty: true
restart: always
```
In this configuration, both ZooKeeper and Kafka are defined as separate services within the same `docker-compose.yml` file. The Kafka service depends on the ZooKeeper service using the `depends_on` keyword. You can save this content into a file named `docker-compose.yml` and run `docker-compose up -d` to start both containers.
阅读全文