我正在尝试使用Docker构建环境,使用两个MySQL服务器和一个phpMyAdmin服务器,以便在开发过程中轻松分析数据。
version: "3.9"
services:
database1:
container_name: Database1
image: mysql:8.0.28
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_DATABASE: database1
MYSQL_ROOT_PASSWORD: somepassword
MYSQL_USER: databaseuser1
MYSQL_PASSWORD: databaseuser1
ports:
- "3306:3306"
volumes:
- database-volume:/var/lib/mysql
networks:
- my_network
database2:
container_name: Database2
image: mysql:8.0.28
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_DATABASE: database2
MYSQL_ROOT_PASSWORD: somepassword
MYSQL_USER: databaseuser2
MYSQL_PASSWORD: databaseuser2
ports:
- "3307:3306"
volumes:
- second-database-volume:/var/lib/mysql
networks:
- my_network
phpmyadmin:
container_name: PhpMyAdmin
image: phpmyadmin/phpmyadmin:5.1.3
restart: always
depends_on:
- database1
- database2
environment:
PMA_HOST: database1, database2
PMA_PORT: 3306, 3307
PMA_USER: databaseuser1, databaseuser2
PMA_PASSWORD: databaseuser1, databaseuser2
ports:
- "8080:80"
networks:
- my_network
volumes:
database-volume:
second-database-volume:
networks:
my_network:
driver: bridge
我想知道是否有任何内置的方式来存档这一点。
1条答案
按热度按时间ru9i0ody1#
您是否尝试过将环境变量
PMA_HOST
更改为PMA_HOSTS
?Official phpMyAdmin Docker image