Reputation: 1011
i'm trying to connect phpmyadmin with mysql database through docker containers
I have the following docker-compose.yml file
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
I tried to log in to PMA using root account and the given password: blabla. I receive the following error:
Upvotes: 4
Views: 5941
Reputation: 3699
Seems "database" is not in phpmyadmin's container /etc/hosts (it's not linked)
Try links:
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
Upvotes: 2