version: '3'
services:
#mysql服务
mysql5.7:
restart: always
image: mysql:5.7
container_name: docker_mysql
environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_USER: 'root'
MYSQL_PASS: "123456"
volumes:
- /opt/mysql/conf:/etc/mysql/conf.d
- /opt/mysql/logs:/logs
- /opt/mysql/data:/var/lib/mysql
ports:
- "3306:3306"
#redis服务
redis:
restart: always
image: redis:latest
container_name: docker_redis
volumes:
- /opt/redis.data:/data
- /opt/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf
- /opt/redis/logs:/logs
ports:
- "6379:6379"
#nginx服务 不加容器挂载启动,再把容器中的目录cp到宿主机对应的目录,删除容器,加上挂载重新启动一个容器
# docker cp docker_nginx:/etc/nginx/conf.d /opt/nginx/conf.d
# docker cp docker_nginx:/var/log/nginx /opt/nginx/log
# docker cp docker_nginx:/etc/nginx/nginx.conf /opt/nginx/conf/nginx.conf
nginx:
restart: always
image: nginx:latest
container_name: docker_nginx
volumes:
- /opt/nginx/conf.d:/etc/nginx/conf.d
- /opt/nginx/log:/var/log/nginx
- /opt/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
#sentinel-dashboard服务
sentinel-dashboard:
restart: always
image: bladex/sentinel-dashboard:latest
container_name: docker_sentinel-dashboard
volumes:
- /opt/sentinel-dashboard/logs:/root/logs
ports:
- "8858:8858"
#mongo服务
#docker cp docker_mongodb:/data/db /opt/mongo
#docker cp docker_mongodb:/docker-entrypoint-initdb.d/ /opt/mongo/mongo-entrypoint
mongo:
restart: always
image: mongo:latest
container_name: docker_mongodb
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=123456
volumes:
- /opt/mongo:/data/db
- /opt/mongo/mongo-entrypoint/:/docker-entrypoint-initdb.d/
ports:
- "27017:27017"
command: mongod
#rabbitmq服务
# 坑1:服务启动后管理界面出不来,依次执行一下命令才能出来
# docker ps
# docker exec -it 镜像ID /bin/bash
# rabbitmq-plugins enable rabbitmq_management
# 坑2:先把挂载注释掉,在cp文件 本地挂载目录需要通过 docker cp 容器名称:/etc/rabbitmq /opt/rabbitmq/etc 命令把容器对应的目录copy到本地
# 删掉容器,加上挂载新建容器
# 坑3: chmod 777 /opt/rabbitmq/etc chmod 777 /opt/rabbitmq/data chmod 777 /opt/rabbitmq/log
rabbitmq:
hostname: rabbitmq
image: rabbitmq:management
container_name: docker_rabbitmq
privileged: true
restart: always
environment:
RABBITMQ_DEFAULT_USER: "admin"
RABBITMQ_DEFAULT_PASS: "123456"
volumes:
- /opt/rabbitmq/etc:/etc/rabbitmq
- /opt/rabbitmq/data:/var/lib/rabbitmq
- /opt/rabbitmq/log:/var/log
ports:
- "5672:5672"
- "15672:15672"
#nacos服务
nacos:
restart: always
image: nacos/nacos-server:latest
container_name: docker_nacos-server
ports:
- "8848:8848"
depends_on:
- mysql5.7
environment:
PREFER_HOST_MODE: hostname #如果支持主机名可以使用hostname,否则使用ip,默认也是ip
SPRING_DATASOURCE_PLATFORM: mysql #数据源平台 仅支持mysql或不保存empty
MODE: standalone
MYSQL_SERVICE_HOST: mysql5.7
MYSQL_SERVICE_DB_NAME: nacos_config
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_USER: root
MYSQL_SERVICE_PASSWORD: 123456
NACOS_APPLICATION_PORT: 8848
JVM_XMS: 512m
JVM_MMS: 320m
volumes:
- /opt/nacos/standalone-logs/:/home/nacos/logs
- /opt/nacos/plugins/:/home/nacos/plugins
- /opt/nacos/conf/application.properties:/home/nacos/conf/application.properties
ports:
- "8848:8848"
#seata-server服务
# docker cp docker_seata-server:/seata-server /opt/seata
seata-server:
restart: always
image: seataio/seata-server
container_name: docker_seata-server
environment:
- SEATA_PORT=8091
- SEATA_IP=10.253.96.110
- STORE_MODE=db
volumes:
- /opt/seata/seata-server:/seata-server
ports:
- "8091:8091"
#elasticsearch服务
# chmod 777 /opt/elasticsearch/data
# chmod 777 /opt/elasticsearch/config
#docker cp elasticsearch:/usr/share/elasticsearch/data /opt/elasticsearch/data
#docker cp elasticsearch:/usr/share/elasticsearch/config /opt/elasticsearch/config
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
container_name: docker_elasticsearch
restart: always
environment:
- cluster.name=my.es
- "discovery.type=single-node"
volumes:
- /opt/elasticsearch/data:/usr/share/elasticsearch/data
- /opt/elasticsearch/config:/usr/share/elasticsearch/config
ports:
- 9200:9200
- 9300:9300
#kibana服务
kibana:
restart: always
image: kibana:7.6.1
container_name: kibana
privileged: true
depends_on:
- elasticsearch #kibana在elasticsearch启动之后再启动
environment:
- "elasticsearch.hosts=http://10.253.96.110:9200" #设置访问elasticsearch的地址
#volumes:
#- /opt/kibana/config:/usr/share/kibana/config #配置文件挂载
ports:
- 5601:5601
#logstash服务
logstash:
image: logstash:7.1.0
container_name: logstash
privileged: true
volumes:
- /opt/logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf:rw
- /opt/logstash/logstash.yml:/usr/share/logstash/config/logstash.yml:rw
network_mode: "host"
#filebeat服务
filebeat:
restart: always
image: docker.elastic.co/beats/filebeat:7.3.0
container_name: filebeat
user: root
privileged: true
volumes:
- /opt/filebeat/filebeat.docker.yml:/usr/share/filebeat/filebeat.yml:rw
- /opt/filebeat/data:/usr/share/filebeat/data:rw
depends_on:
- elasticsearch
#- es02
- logstash
- kibana
#代码生成服务
code-generator:
restart: always
build:
context: .
dockerfile: generatorDockerfile
image: code-generator
container_name: docker_code-generator
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/code-generator:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6500:6500"
#网关服务
gateway:
restart: always
build:
context: .
dockerfile: gatewayDockerfile
image: gateway
container_name: docker_gateway
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/gateway:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6501:6501"
#分布式定时任务服务
xxl-job-admin:
image: xuxueli/xxl-job-admin:2.2.0
restart: always
container_name: xxl-job-admin
environment:
PARAMS: '--spring.datasource.url=jdbc:mysql://10.253.96.110:3306/lly_xxljob?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=123456'
ports:
- 6502:8080
volumes:
- /opt/xxl-job:/data/applogs
#日志服务
action:
restart: always
build:
context: .
dockerfile: actionDockerfile
image: action
container_name: docker_action
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/action:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6503:6503"
#接口key管理服务
apikey:
restart: always
build:
context: .
dockerfile: apikeyDockerfile
image: apikey
container_name: docker_apikey
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/apikey:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6504:6504"
#数据字典服务
basedata:
restart: always
build:
context: .
dockerfile: basedataDockerfile
image: basedata
container_name: docker_basedata
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/basedata:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6505:6505"
#文件系统服务
file-system:
restart: always
build:
context: .
dockerfile: fileDockerfile
image: file-system
container_name: docker_file-system
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/file-system:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6506:6506"
#鉴权中心服务
oauth:
restart: always
build:
context: .
dockerfile: oauthDockerfile
image: oauth
container_name: docker_oauth
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/oauth:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6507:6507"
#用户中心管理服务
usercenter:
restart: always
build:
context: .
dockerfile: usercenterDockerfile
image: usercenter
container_name: docker_usercenter
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/usercenter:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6508:6508"
#消息中心服务
message:
restart: always
build:
context: .
dockerfile: messageDockerfile
image: message
container_name: docker_message
privileged: true
environment:
# 指定时区
- TZ="Asia/Shanghai"
volumes:
# 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
- /opt/data/logs/message:/logs
# 指定容器时间为宿主机时间
- /etc/localtime:/etc/localtime
ports:
- "6509:6509"