环境依赖
Nacos:v2.1.0
MySQL:8.0.21
Seata:1.5.0
nacos依赖MySql;
Seata依赖Nacos+Mysql
涉及到的点
deploy部署设置、depends_on执行顺序设置、自定义网段
完整配置
version: '3.9'
services:
#mysql数据库脚本
db:
image: mysql:8.0.21
container_name: mysql
hostname: mysql-node1
restart: always
ports:
- 3306:3306
volumes:
- ./mysql/logs:/var/log/mysql
- ./mysql/data:/var/lib/mysql
- ./mysql/conf/my.cnf:/etc/my.cnf
- ./mysql/init:/docker-entrypoint-initdb.d/
environment:
MYSQL_ROOT_PASSWORD: ltingzx
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 5s
retries: 2
start_period: 5s
security_opt:
- seccomp:unconfined
networks:
extnetwork:
ipv4_address: 172.21.0.2
#nacos服务脚本
nacos:
image: nacos/nacos-server:v2.1.0
container_name: nacos
hostname: nacos-node1
restart: always
ports:
- "8848:8848"
volumes: #挂载目录
- ./nacos/logs/:/home/nacos/logs
- ./nacos/data/:/home/nacos/data
environment:
SPRING_DATASOURCE_PLATFORM: mysql #数据源平台 仅支持mysql或不保存empty
MODE: standalone
MYSQL_SERVICE_HOST: mysql
MYSQL_SERVICE_DB_NAME: nacos
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_USER: root
MYSQL_SERVICE_PASSWORD: ltingzx
NACOS_APPLICATION_PORT: 8848
JVM_XMS: 512m
JVM_MMS: 256m
JVM_XMN: 128m
MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=10000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
networks:
extnetwork:
ipv4_address: 172.21.0.3
deploy:
restart_policy:
delay: 5s
max_attempts: 10
healthcheck:
test: ["CMD-SHELL", "echo 'ruok' | curl -s telnet://localhost:8848 || exit 1"]
interval: 3s
timeout: 5s
retries: 3
start_period: 5s
depends_on:
db:
#condition: service_started
condition: service_healthy
#condition: service_completed_successfully
#seata服务脚本
seata:
image: seataio/seata-server:1.5.0
container_name: seata-server
restart: always
ports:
- "9200:9200"
- "7091:7091"
volumes:
- ./seata-server/mysql-connector-java-8.0.25.jar:/seata-server/libs/mysql-connector-java-8.0.25.jar
- ./seata-server/config/application.yml:/seata-server/resources/application.yml
- ./seata-server/logs:/root/logs/seata
environment:
SEATA_IP: