P. Kein
P. Kein

Reputation: 21

Incorrect docker compose on phpmyadmin

According to the docker compose yaml,

version: '3'
services:
  db:
    image: mariadb:latest
    container_name: mariadb
    restart: always
    volumes:
      - ./mysql/initdb/:/docker-entrypoint-initdb.d
      - ./mysql/data/:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=root-pwd
      - MYSQL_DATABASE=appdb
      - MYSQL_USER=appuser
      - MYSQL_PASSWORD=user-pwd
  php:
    image: php:fpm-alpine
    container_name: php
    restart: always
    volumes:
      - ./www/:/var/www/html
    expose:
      - "9000"
  nginx:
    image: nginx:alpine
    container_name: nginx
    restart: always
    volumes:
      - ./nginx/conf/nginx.conf:/etc/nginx/conf/nginx.conf:ro
      - ./nginx/conf.d:/etc/nginx/conf.d:ro
      - ./www:/var/www/html
    ports:
      - "80:80"
  pma:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    restart: always
    ports:
      - "8080:80"

it produces an error:

#2002 - php_network_getaddresses: getaddrinfo failed: Try again — The server is not responding (or the local server's socket is not correctly configured).

when logging in to phpMyadmin (http://127.0.0.1:8080).

I have tried to fix this problem, but nothing works. Could you please find a solution? Any recommendations/comments are welcomed here.

Upvotes: 0

Views: 2256

Answers (3)

vivanov
vivanov

Reputation: 1522

If you set the following environment variable in docker compose:

pma:
  environment:
    - PMA_ARBITRARY=1

then you will be given the opportunity to enter the host server manually on the login screen. Enter the name of the database service there. In your case the name of the service is db

Upvotes: 0

Ravi
Ravi

Reputation: 11

I had a similar problem try this in the links directive - container-name:db as below

links: - mariadb:db

Upvotes: 1

Fendi jatmiko
Fendi jatmiko

Reputation: 2895

you should links your phpmyadmin to database services in order to use the db service

pma:
    image: phpmyadmin/phpmyadmin
    links:
      - db
    container_name: phpmyadmin
    restart: always
    ports:
      - "8080:80"
    environment:
      - PMA_HOST: maria_db

here is more about docker compose services links

Upvotes: 0

Related Questions