开发环境依赖组件容器化配置参考

为避免开发时总是需要耗时搭建开发依赖的组件,因此维护一个 docker-compose 用于快速部署依赖组件环境

组件

  • elasticsearch:8.8.0
  • kibana:8.8.0
  • redis:7.0.11
  • mysql:8
  • postgres:15
  • grafana-enterprise

docker-compose

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
version: '3'

services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.8.0
container_name: elasticsearch8
restart: always
environment:
- discovery.type=single-node
- ELASTIC_PASSWORD=<Your_ELASTIC_PASSWORD>
ports:
- "9200:9200"
volumes:
- esdata:/usr/share/elasticsearch/data


kibana:
image: docker.elastic.co/kibana/kibana:8.8.0
container_name: kibana8
restart: always
environment:
- SERVER_NAME=kibana
- XPACK_SECURITY_ENABLED=true
ports:
- "5601:5601"
volumes:
- kibanadata:/usr/share/kibana/data

redis:
image: redis:7.0.11
container_name: redis7
restart: always
# 修改密码以及绑定地址
command: redis-server --requirepass "<your_redis_pass>" --bind 0.0.0.0
ports:
- "6379:6379"
volumes:
- redisdata:/data

mysql:
image: mysql:8
container_name: mysql8
restart: always
command: --default-authentication-plugin=caching_sha2_password
environment:
MYSQL_ROOT_PASSWORD: <root_pass>
MYSQL_DATABASE: <your_db>
MYSQL_USER: <your_user>
MYSQL_PASSWORD: <your_pass>
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql

postgres:
image: postgres:15
container_name: postgres15
restart: always
environment:
POSTGRES_DB: database # 设置数据库名称
POSTGRES_USER: user # 设置数据库用户
POSTGRES_PASSWORD: PasswOrd # 设置数据库密码
volumes:
- postgres_data:/var/lib/postgresql/data # 数据持久化存储的路径
ports:
- "5432:5432" # 将容器的 5432 端口映射到宿主机的 5432 端口

grafana: # 默认账号密码: admin/admin
image: grafana/grafana-enterprise
container_name: grafana
restart: unless-stopped
environment:
- GF_INSTALL_PLUGINS=grafana-clock-panel
ports:
- '3000:3000'
volumes:
- grafana-storage:/var/lib/grafana

volumes:
esdata:
kibanadata:
redisdata:
mysql_data:
postgres_data:
grafana-storage: