---
# System prepended metadata

title: 建立單機kafka

---

# 建立單機kafka
- 使用 wurstmeister/kafka
https://hub.docker.com/r/wurstmeister/kafka
--------
1. 安裝 docker-compose https://docs.docker.com/compose/install/
2. 建立 docker-compose.yml，內容如下
```
version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka:
    image: wurstmeister/kafka
    ports:
      - "9092"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
```
3. 打開terminal，執行
```
docker-compose up -d
```