我试图通过docker containers连接phpmyadmin和mysql数据库
我有以下docker-compose.yml文件
version: "3"
services:
database:
image: mysql:latest
container_name: locations-service-mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- ./mysql-init:/var/lib/mysql:rw
- ./mysql-init/locations_schema.sql:/docker-entrypoint-
initdb.d/locations_schema.sql:ro
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
ports:
- 8181:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: examplepass
PMA_HOST: database
dropwizard:
build: ../locations-service/
ports:
- 8080:8080
- 8081:8081
- 5005:5005
depends_on:
- database
container_name: locations-service
我尝试使用root帐户和给定密码登录PMA:blabla。 我收到以下错误:
答案 0 :(得分:2)
似乎"数据库"不在phpmyadmin的容器/ etc / hosts中(它没有链接)
尝试链接:
version: "3"
services:
database:
image: mysql:latest
container_name: locations-service-mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- ./mysql-init:/var/lib/mysql:rw
- ./mysql-init/locations_schema.sql:/docker-entrypoint-initdb.d/locations_schema.sql:ro
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
links:
- database
ports:
- 8181:80
environment:
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: examplepass
PMA_HOST: database