skip to Main Content

I am a beginner in Docker.

I’m trying login in phpMyAdmin + Laravel + Docker, but I couldn’t do it. I’m confused. The Docker image that is used in many tutorials was removed from Docker. I’m using the follow image:

https://hub.docker.com/_/phpmyadmin

enter image description here

docker-compose.yml

version: '3.8'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
    mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: 123456
            MYSQL_DATABASE: fastfood-api
            MYSQL_USER: root
            MYSQL_PASSWORD: 123456
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
    phpmyadmin:
        image: 'phpmyadmin'
        container_name: pma
        environment:
            PMA_HOST: mysql
            PMA_PASSWORD: 123456
            PMA_ARBITRARY: 1
        restart: always
        ports:
            - 8081:80
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local

From Workbench, it get a connection.

2

Answers


  1. Is ‘sail’ a user defined network? What are its properties?
    The simplest way to troubleshoot would be to do:

    docker exec -it your_phpmyadmin_container bash

    Then see if you can ‘ping mysql’ for connectivity.
    I imagine that the bridge is default therefore connectivity won’t be available via the host/service names, so you can either use the deprecated -link option to enable it or create a user defined network called sail.

    https://docs.docker.com/network/bridge/#differences-between-user-defined-bridges-and-the-default-bridge

    Login or Signup to reply.
  2. you must add network: -sail in PHPMyAdmin because the phpmyadmin container isn’t on that network.

    like this code.
    if still doesn’t work see this MYSQL_ROOT_PASSWORD is set but getting "Access denied for user 'root'@'localhost' (using password: YES)" in docker container

       phpmyadmin:
            image: 'phpmyadmin'
            container_name: pma
            environment:
                PMA_HOST: mysql
                PMA_PASSWORD: 123456
                PMA_ARBITRARY: 1
            restart: always
            ports:
                - 8081:80
            networks:
                - sail
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search