M1M6
M1M6

Reputation: 1011

#2002 getaddrinfo failed - phpmyadmin using docker container

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:

2002 - php_network_getaddresses: getaddrinfo failed: Name does not resolve — The server is not responding (or the local server's socket is not correctly configured).

Upvotes: 4

Views: 5941

Answers (1)

Alfonso Tienda
Alfonso Tienda

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

Related Questions