skip to Main Content

I am trying to set up a docker-pod with laravel, mariadb, nginx, redis and phpmyadmin. The laravel webspace works finde but if i switch to port 10081 like configured in the docker-compose.yml i am not able to login with the root account.

it sais " mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution"

i already tried to configure a "my-network" which links all of the container, but if i understand docker right there is already a "defaul" network which does this. It didnt change the error message anyway.

here is my full docker-compose file

version: "3.8"
services:
  redis:
    image: redis:6.0-alpine
    expose:
      - "6380"

  db:
    image: mariadb:10.4
    ports:
      - "3307:3306"
    environment:
      MYSQL_USERNAME: root
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: laravel
    volumes:
      - db-data:/var/lib/mysql

  nginx:
    image: nginx:1.19-alpine
    build:
      context: .
      dockerfile: ./docker/nginx.Dockerfile
    restart: always
    depends_on:
      - php
    ports:
      - "10080:80"
    networks:
      - default
    environment:
      VIRTUAL_HOST: cockpit.example.de
    volumes:
      - ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./public:/app/public:ro

  php:
    build:
      target: dev
      context: .
      dockerfile: ./docker/php.Dockerfile
    working_dir: /app
    env_file: .env
    restart: always
    expose:
        - "9000"
    depends_on:
      - composer
      - redis
      - db
    volumes:
      - ./:/app
      - ./docker/www.conf:/usr/local/etc/php-fpm.d/www.conf:ro
    links:
      - db:mysql


  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    ports:
      - 10081:80
    restart: always
    environment:
      PMA_HOST : db
      MYSQL_USERNAME: root
      MYSQL_ROOT_PASSWORD: secret
    depends_on:
      - db
    #user: "109:115"
    links:
      - db:mysql
      
  node:
    image: node:12-alpine
    working_dir: /app
    volumes:
      - ./:/app
    command: sh -c "npm install && npm run watch"

  composer:
    image: composer:1.10
    working_dir: /app
    #environment:
      #SSH_AUTH_SOCK: /ssh-auth.sock
    volumes:
      - ./:/app
      #- "$SSH_AUTH_SOCK:/ssh-auth.sock"
      - /etc/passwd:/etc/passwd:ro
      - /etc/group:/etc/group:ro
    command: composer install --ignore-platform-reqs --no-scripts

volumes:
  db-data:

2

Answers


  1. Maybe your container cannot start because its volume contains incompatible data. It can happen if you downgrade the version of mysql or mariadb image.

    You can resolve the problem if you remove the volume and import the database again. Maybe you have to create a backup first.

    Login or Signup to reply.
  2. Make sure you have defined all attributes correctly for phpmyadmin container, in the current case there was the absence of -network definition

    phpmyadmin:
      image: phpmyadmin/phpmyadmin:latest
      container_name: phpmyadmin
      restart: always
      ports:
        # 8080 is the host port and 80 is the docker port
         - 8080:80
      environment:
        - PMA_ARBITRARY:1
        - PMA_HOST:mysql
        - MYSQL_USERNAME:root
        - MYSQL_ROOT_PASSWORD:secret
      depends_on:
        - mysql
      networks:
      # define your network where all containers are connected to each other
        - laravel
      volumes:
      # define directory path where you shall store your persistent data and config 
      # files of phpmyadmin 
        - ./docker/phpmyadmin
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search