我正在尝试通过 Traefik 设置对 MariaDb 的远程访问:
MariaDB docker-compose.yml
version: "2"
services:
jpz-mariadb:
image: mariadb:latest
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=database
- MYSQL_USER=user
- MYSQL_PASSWORD=pass
networks:
- web
volumes:
- ./db:/docker-entrypoint-initdb.d
- jpz-mariadb:/var/lib/mysql:nocopy # I want to manage volumes manually.
labels:
- 'traefik.backend=jpz-mariadb'
- 'traefik.frontend.rule=Host:mariadb.localtest.me'
jpz-pma:
image: phpmyadmin/phpmyadmin
environment:
PMA_HOST: jpz-mariadb
PHP_UPLOAD_MAX_FILESIZE: 1G
PHP_MAX_INPUT_VARS: 1G
networks:
- web
labels:
- 'traefik.backend=jpz-pma'
- 'traefik.frontend.rule=Host:pma.localtest.me'
volumes:
jpz-mariadb:
external: true
networks:
web:
external:
name: traefik_webgateway
和 Traefik docker-compose.yml
version: '2'
services:
proxy:
image: traefik
command: --web --docker --docker.domain=localtest.me --logLevel=DEBUG
networks:
- webgateway
ports:
- "81:80"
- "3307:3306"
- "443:443"
- "8081:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /dev/null:/traefik.toml
networks:
webgateway:
driver: bridge
我无法通过以下方式连接到 mariadb.localtest.me:3307mysql -u root -p -h mariadb.localtest.me -P 3307
得到:
在“读取初始通信数据包”时失去与 MySQL 服务器的连接,系统错误:0 (Mysql2::Error)
如何解决?
谢谢