我正在嘗試使用Docker建置環境,其中包括兩個MySQL伺服器和一個phpMyAdmin伺服器,以便在開發過程中輕鬆分析資料。 我的docker-compose.yml檔案如下。
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
我想知道是否有內建的方法來實現這個目標。
你是否嘗試將環境變數
PMA_HOST
改為PMA_HOSTS
?官方phpMyAdmin Docker映像