dockerphpmyadmine-commerceshopwareshopware6

Shopware 6 Docker Setup add PHPMyAdmin


I am a totally beginner at Shopware and I want to use PhpMyAdmin for my local Shopware 6 setup.

For the download I used the official Shopware 6 Development repository https://github.com/shopware/development

I've already seen that the docker-compose.yml has implemented the following:

app_mysql:
    build: dev-ops/docker/containers/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: app
      MYSQL_PASSWORD: app
    networks:
      shopware:
        aliases:
          - mysql

and now I want to implement phpmyadmin. I tried the following:

phpmyadmin:
      image: phpmyadmin/phpmyadmin
      links:
          - app_mysql:mysql
      depends_on:
          - app_mysql
      ports:
          - 8181:80
      environment:
          PMA_HOST: app_mysql
          MYSQL_ROOT_PASSWORD: root
          MYSQL_USER: app
          MYSQL_PASSWORD: app

phpmyadmin is visible on localhost:8181 but when I try to login I get the following errors:

mysqli::real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known mysqli::real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known

How can I solve it?


Solution

  • Usually phpmyadmin should be in the same network as the database.
    Service names are resolved to the IP addresses of the containers, therefore it's recommended to use names allowed by RFC1035 to avoid additional problems.

    I removed links:, aliases, depends_on that are deprecated/not required and ended up with this docker-compose.yml.

    version: '3.7'
    services:
      app-mysql:
        #build: dev-ops/docker/containers/mysql
        image: mysql
        environment:
          MYSQL_ROOT_PASSWORD: root
          MYSQL_USER: app
          MYSQL_PASSWORD: app
        networks:
          - shopware
      phpmyadmin:
        image: phpmyadmin/phpmyadmin
        ports:
            - 8181:80
        environment:
          PMA_HOST: app-mysql
          PMA_PORT: 3306
          PMA_ARBITRARY: 1
        networks:
          - shopware
    networks:
      shopware
    

    Run the containers:

    docker-compose up
    

    Open http://localhost:8181/index.php in a browser. Use

    Server:    app-mysql
    Username:  root
    Password:  root
    

    Enjoy:

    enter image description here