@uncleChen
version: "3"
services:
halo_server:
image: halohub/halo:1.5.3
container_name: halo_server
restart: on-failure:3
depends_on:
- halo_mysql
networks:
halo_network:
volumes:
- ./:/root/.halo
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "8090:8090"
environment:
- SERVER_PORT=8090
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=com.mysql.cj.jdbc.Driver
- SPRING_DATASOURCE_URL=jdbc:mysql://halo_mysql:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
- SPRING_DATASOURCE_USERNAME=root
- SPRING_DATASOURCE_PASSWORD=123456
- HALO_ADMIN_PATH=admin
- HALO_CACHE=memory
halo_mysql:
image: mysql:8.0.27
container_name: halo_mysql
restart: on-failure:3
networks:
halo_network:
command: --default_authentication_plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
volumes:
- /etc/localtime:/etc/localtime:ro
- ./mysql/data:/var/lib/mysql
- ./mysql/logs:/var/log/mysql
- ./mysql/conf:/etc/mysql/conf.d
ports:
- "3301:3306"
environment:
#
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=halodb
networks:
halo_network:
试试改为这样(SPRING_DATASOURCE_URL
中的 MySQL 端口改为 3306),这可能是因为给他们设置了同一个网络 halo_network
,所以相对于 Halo 的容器来说,MySQL 的服务端口并不是你设置的 3301, 3301 端口应该只是暴露给宿主机的端口。