共计 1130 个字符,预计需要花费 3 分钟才能阅读完成。
xxljob docker compose deploy: could not create connection to database server
docker-compose.yaml file
version: '2'
services:
xxl-job:
container_name: xxl-job
image: xuxueli/xxl-job-admin:2.3.1
ports:
- 8080:8080
links:
- mysql
depends_on:
- mysql
environment:
PARAMS: '--spring.datasource.url=jdbc:mysql://mysql:3306/xxl_job?useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&serverTimezone=Asia/Shanghai --spring.datasource.username=root --spring.datasource.password=root --xxl.job.accessToken=dasj2nd81jf9asjdkl5jk234'
networks:
- xxl_job_net
mysql:
container_name: mysql
image: mysql
restart: always
ports:
- 13306:3306
volumes:
- .:/docker-entrypoint-initdb.d
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: xxl_job
networks:
- xxl_job_net
networks:
xxl_job_net:
driver: bridge
>>> docker compose up
Could not create connection to database server
解决方案:
1 查问 docker mysql ip address
>>> docker inspect mysql | grep IPAddress
# 172.18.0.2
2 替换 docker-compose.yaml 文件中 PARAMS spring.datasource.url 值
--spring.datasource.url=jdbc:mysql://mysql:3306/xxl_job
替换为
--spring.datasource.url=jdbc:mysql://172.18.0.2:3306/xxl_job
3 docker compose up
连贯胜利
正文完