Docker Community Forums

Share and learn in the Docker community.

Docker-compose drupal mysql SQLSTATE[HY000] [2002] No such file or directory

Hi All, Please help. posted 3 days ago, but didnt got any ans.

version: '3.1'
services:
  drupal:
    image: drupal:8
    container_name: drupal_container
    environment:
     DRUPAL_PROFILE: standard
     DRUPAL_SITE_NAME: Drupal
     DRUPAL_USER: user
     DRUPAL_PASS: pass
     DRUPAL_DBURL: mysql://user:pass@database:3306/db
    #or mysql://user:pass@mysql_container:3306/db tried with both
    links:  
     - "mysql:mysql"
    depends_on:
     - mysql
    ports:
     - 80:80
    restart: always
    volumes:
     - /var/www/html/modules
     - /var/www/html/profiles
     - /var/www/html/themes
     - /var/www/html/sites
    restart: always
  mysql:
    image: mysql:5.7
    container_name: mysql_container
    restart: always
    environment:
     MYSQL_ROOT_PASSWORD: root
     MYSQL_DATABASE: db
     MYSQL_USER: user
     MYSQL_PASSWORD: pass
    ports:
     - 3306:3306
    expose:
     - 3306

Just tell me when you get this message?
On composing or installing?
I think when on installing drupal. When you have to type database like database user name, database password, database name

Click on Advanced Option

From database server Remove “localhost” . And type “mysql”

Please give me feedback what happened