Docker : Drupal container linked to mysql container can't connect to mysql during Drupal installation

Vincent Space

I'm fairly new to docker, and I've just been going through the CMS's to see how easy they are to configure. So far, Wordpress and Joomla check out.

When I run the drupal container linked to mysql, I get to the drupal installation screen and where it says to connect the DB, and I use my root credentials and db host being 'localhost', and receive errors trying to connect. I've attached an image to show you the output.drupal-config-db-output-error

The error I get :

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.

Any help on this would be great. I tried to see if I could access the physical the volume with the config files, but I couldn't find them using Kitematic.

Thank you!

Mark O'Connor

The following docker compose file will startup Drupal connected to another container running Mysql

db:
  image: mysql
  environment:
    - MYSQL_ROOT_PASSWORD=letmein
    - MYSQL_DATABASE=drupal
    - MYSQL_USER=drupal
    - MYSQL_PASSWORD=drupal
  volumes:
    - /var/lib/mysql
web:
  image: drupal
  links:
    - db:mysql
  ports:
    - "8080:80"
  volumes:
    - /var/www/html/sites
    - /var/www/private

Note that the drupal container uses docker links. This will create a /etc/hosts entry called "mysql". Use this instead of "localhost" when running the drupal install screens.


Note

The docker compose file syntax has changed since this answer was originally drafted.

Here is the updated syntax

version: '2'
services:
  mysql:
    image: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=letmein
      - MYSQL_DATABASE=drupal
      - MYSQL_USER=drupal
      - MYSQL_PASSWORD=drupal
    volumes:
      - /var/lib/mysql
  web:
    image: drupal
    depends_on:
      - mysql
    ports:
      - "8080:80"
    volumes:
      - /var/www/html/sites
      - /var/www/private

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Can't connect to mySql docker container with JDBC

From Dev

Can't connect to MySQL docker container

From Dev

Mysql installation on docker container

From Dev

Mysql installation on docker container

From Dev

Can't connect to MySQL docker container launched via ansible

From Dev

Can't connect Docker Wordpress container to MySQL on host

From Dev

Unable to Connect MySQL container to Tomcat Container in docker

From Dev

docker nodejs container cant connect mysql container

From Dev

Docker mysql cant connect to container

From Dev

Can't connect to Docker container

From Dev

Can't connect to MySQL docker container created via docker-compose

From Dev

Why I can't connect to mysql docker container through JDBC with another database user than root?

From Dev

Docker + MYSQL: Can't access mysql outside the container

From Dev

connect mysql client container to mysql server container Docker

From Dev

How to populate a Mysql docker container during build of another container?

From Dev

Error while connecting to MySQL on local docker container: ERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (115)

From Java

Connect to Docker MySQL container from localhost?

From Dev

connect to mysql database from docker container

From Dev

How to connect external mysql server in docker container

From Dev

How to connect my host mysql in docker container?

From Dev

How to connect external mysql server in docker container

From Dev

connect to mysql database from docker container

From Dev

how to connect remote docker container mysql server

From Dev

Cannot connect to mysql from within a docker container

From Dev

Docker Container can't connect to the Internet

From Dev

Can't set custom configuration file for mysql docker container

From Dev

Can't connect to Postgres docker container from Golang container

From Java

Docker Can't connect to linked container on the same network - all other containers working

From Dev

docker cp doesn't work for this mysql container

Related Related

  1. 1

    Can't connect to mySql docker container with JDBC

  2. 2

    Can't connect to MySQL docker container

  3. 3

    Mysql installation on docker container

  4. 4

    Mysql installation on docker container

  5. 5

    Can't connect to MySQL docker container launched via ansible

  6. 6

    Can't connect Docker Wordpress container to MySQL on host

  7. 7

    Unable to Connect MySQL container to Tomcat Container in docker

  8. 8

    docker nodejs container cant connect mysql container

  9. 9

    Docker mysql cant connect to container

  10. 10

    Can't connect to Docker container

  11. 11

    Can't connect to MySQL docker container created via docker-compose

  12. 12

    Why I can't connect to mysql docker container through JDBC with another database user than root?

  13. 13

    Docker + MYSQL: Can't access mysql outside the container

  14. 14

    connect mysql client container to mysql server container Docker

  15. 15

    How to populate a Mysql docker container during build of another container?

  16. 16

    Error while connecting to MySQL on local docker container: ERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (115)

  17. 17

    Connect to Docker MySQL container from localhost?

  18. 18

    connect to mysql database from docker container

  19. 19

    How to connect external mysql server in docker container

  20. 20

    How to connect my host mysql in docker container?

  21. 21

    How to connect external mysql server in docker container

  22. 22

    connect to mysql database from docker container

  23. 23

    how to connect remote docker container mysql server

  24. 24

    Cannot connect to mysql from within a docker container

  25. 25

    Docker Container can't connect to the Internet

  26. 26

    Can't set custom configuration file for mysql docker container

  27. 27

    Can't connect to Postgres docker container from Golang container

  28. 28

    Docker Can't connect to linked container on the same network - all other containers working

  29. 29

    docker cp doesn't work for this mysql container

HotTag

Archive