I know this is a duplicate of this, but since that was never answered, I am re-posting this question.
I am trying to build a basic connection of php-apache and mysql containers.
docker-compose.yml
version: '3.1'
services: 
  php:
    build: 
      context: .
      dockerfile: Dockerfile
    ports: 
      - 80:80
    volumes: 
      - ./src:/var/www/html
  
  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    # Exposing the ports doesn't help either
    # ports:
    #   - 3306:3306
    environment:
      MYSQL_ROOT_PASSWORD: example
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
Dockerfile
FROM php:7.2-apache
RUN docker-php-ext-install mysqli
I run a simple docker-compose up command, and access Adminer on localhost:8080.
However, despite using the default login details, i.e
server: db  
username: root
password: example
I get the error SQLSTATE[HY000] [2002] Connection refused.
I think the issue might be some configuration issue on my local machine, because I couldn't use docker based LAMP stacks made by other people too.
Any help is greatly appreciated,
Thank You!
