关于docker:dockercompose-方式安装kafka

233次阅读

共计 1259 个字符,预计需要花费 4 分钟才能阅读完成。

一、kafka docker-compose.yml 文件

version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka:2.11-0.11.0.3
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://selton.cn:9092
KAFKA_LISTENERS: PLAINTEXT://:9092
KAFKA_ZOOKEEPER_CONNECT: selton.cn:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock

二、docker-compose 疾速部署 mysql 和 redis
创立 docker-compose.yml 文件,并填写如下配置。

version: '3'
services:
mysql:
restart: always
privileged: true
image: mysql:8.0
container_name: mysqlServer33106
volumes:
- ./db:/var/lib/mysql
- ./conf:/etc/mysql/conf.d
- ./logs:/logs
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_INITDB_SKIP_TZINFO: "Asia/Shanghai"
ports:
- "33106:3306"
network_mode: "bridge"
redis-dev:
image: redis:5.0.4
container_name: redis
hostname: localhost
network_mode: bridge
command: redis-server /etc/redis.conf #启动 redis 命令
volumes:
- ./redis/redis.conf:/etc/redis.conf
ports:
- "6379:6379"

常用命令总结:

## 启动组件
docker-compose up
# 留神文件名肯定是 docker-compose.yml 能力运行胜利,#若不是这个文件名,则须要指定文件名, filename 对应文件名
docker-compose -f filename up
# 敞开 docker-compose 服务
docker-compose down
# 或者
docker-compose -f filename down
其余常用命令能够通过 docker-compose --help 查看

参考: https://blog.csdn.net/oschina…

正文完
 0