数据库及初始化示例
目录结构如下:
- docker
docker-compose.yaml
scripts
sql
- db
- init.sql
- update.sql
- db
version: '3'
services:
mysql:
image: mysql:5.7
command: --character-set-server=utf8mb4
container_name: mysql
restart: always
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123456
ports:
- "3306:3306"
volumes:
- type: bind
source: ./scripts/sql/db
target: /docker-entrypoint-initdb.d
redis示例
version: '3'
services:
redis:
image: redis
container_name: redis
restart: always
ports:
- "6379:6379"
clickhouse 构建示例
version: '3'
services:
clickhouse:
image: yandex/clickhouse-server
container_name: click-house
ports:
- "8123:8123"
- "9000:9000"
environment:
- CLICKHOUSE_PASSWORD=123456
- CLICKHOUSE_DB=default
volumes:
- ./scripts/sql/ck:/docker-entrypoint-initdb.d # 挂载初始化脚本目录
kafka 构建
Apache Kafka Raft (KRaft) 在 Kafka 中使用了新的仲裁控制器服务,该服务取代了之前的控制器,并使用了 Raft 共识协议的基于事件的变体。这极大地简化了 Kafka 的架构,将元数据的责任整合到 Kafka 本身,而不是将其拆分到两个不同的系统:ZooKeeper 和 Kafka。
https://github.com/bitnami/containers/issues/31580
kafka:
image: 'bitnami/kafka:latest'
hostname: 'bitnami'
ports:
- '9092:9092'
- '9094:9094'
environment:
- TZ=Asia/Shanghai
- KAFKA_ENABLE_KRAFT=yes
- KAFKA_CFG_PROCESS_ROLES=broker,controller
- KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9094
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://bitnami:9092
- KAFKA_CFG_NODE_ID=1
- KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@127.0.0.1:9094
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true
- ALLOW_PLAINTEXT_LISTENER=yes
kafka-ui:
image: provectuslabs/kafka-ui:latest
ports:
- 8080:8080
environment:
- TZ=Asia/Shanghai
- LOGGING_LEVEL_ROOT=error
- LOGGING_LEVEL_COM_PROVECTUS=error
- KAFKA_CLUSTERS_0_NAME=bitnami
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=bitnami:9092
Nsq 构建
作为之前单独启动的补充
version: '3.8'
services:
nsqlookupd:
image: nsqio/nsq
command: /nsqlookupd
networks:
- nsq-network
hostname: nsqlookupd
ports:
- "4161:4161"
- "4160:4160"
nsqd:
image: nsqio/nsq
command: /nsqd --broadcast-address=x.x.x.x --lookupd-tcp-address=nsqlookupd:4160
depends_on:
- nsqlookupd
hostname: nsqd
networks:
- nsq-network
ports:
- "4151:4151"
- "4150:4150"
nsqadmin:
image: nsqio/nsq
command: /nsqadmin --lookupd-http-address=nsqlookupd:4161
depends_on:
- nsqlookupd
hostname: nsqadmin
ports:
- "4171:4171"
networks:
- nsq-network
networks:
nsq-network:
driver: bridge