docker mysql
最后发布时间 : 2024-02-23 13:02:25
浏览量 :
version: "3.0"
services:
# MYSQL
mysql:
container_name: mysql
image: mysql:8.0.26
volumes:
- ./saas/mysql/data:/var/lib/mysql
- ./saas/mysql/conf/my.cnf:/etc/mysql/my.cnf
- ./saas/mysql/mysql-files:/var/lib/mysql-files
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=12345
- MYSQL_DATABASE=nacos
- MYSQL_USER=nacos
- MYSQL_PASSWORD=nacos
- LANG=C.UTF-8
- MYSQL_ROOT_HOST=%
privileged: true
restart: always
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s
timeout: 10s
retries: 10
# Nacos
nacos:
image: nacos/nacos-server:v2.2.3
container_name: nacos-standalone-mysql
environment:
- TZ=Asia/Shanghai
- PREFER_HOST_MODE=hostname
- MODE=standalone
- MYSQL_SERVICE_HOST=mysql
- MYSQL_SERVICE_DB_NAME=nacos
- MYSQL_SERVICE_PORT=3306
- MYSQL_SERVICE_USER=nacos
- MYSQL_SERVICE_PASSWORD=nacos
- MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
volumes:
- ./saas/nacos/logs/:/home/nacos/logs
ports:
- "8848:8848"
- "9848:9848"
restart: always
depends_on:
mysql:
condition: service_healthy
version: "2"
services:
node1:
image: test
hostname: node1
container_name: node1
restart: always
command: sleep 6000
# --default-authentication-plugin=mysql_native_password
# --character-set-server=utf8mb4
# --lower-case-table-names=1
# environment:
# - MYSQL_ROOT_PASSWORD=shanjun0125
# - TZ=Asia/Shanghai
# extra_hosts:
# - "nacos:192.168.128.2"
# - "shanjun_redis:192.168.128.201"
# - "shanjun_mysql:192.168.128.202"
# - "shanjun_zookeeper:192.168.128.203"
# - "shanjun_kafka:192.168.128.204"
networks:
- springcloud
# ipv4_address: 192.168.128.202
node2:
image: test
hostname: node2
container_name: node2
restart: always
command: sleep 6000
# --default-authentication-plugin=mysql_native_password
# --character-set-server=utf8mb4
# --lower-case-table-names=1
# environment:
# - MYSQL_ROOT_PASSWORD=shanjun0125
# - TZ=Asia/Shanghai
# extra_hosts:
# - "nacos:192.168.128.2"
# - "shanjun_redis:192.168.128.201"
# - "shanjun_mysql:192.168.128.202"
# - "shanjun_zookeeper:192.168.128.203"
# - "shanjun_kafka:192.168.128.204"
networks:
- springcloud
# ipv4_address: 192.168.128.202
networks:
springcloud:
external: true