Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Docker container not working #1856

Closed
adaltavo opened this issue Nov 6, 2018 · 10 comments · Fixed by #1973
Closed

Docker container not working #1856

adaltavo opened this issue Nov 6, 2018 · 10 comments · Fixed by #1973

Comments

@adaltavo
Copy link

adaltavo commented Nov 6, 2018

Issue Type

  • Bug Report / Support Request

Your Environment

Docker CE  18.09.0-ce-beta1 for MacOS (Edge version)

Your OS

  • macOS (10.13.6)

Full console output

gist

Summary

using docker container with tag "latest", when running the command:
docker exec drupalvm install-drupal

after a while shows the following output:

In SiteInstallCommands.php line 354:
                                                                               
  Failed to create database: ERROR 2002 (HY000): Can't connect to local MySQL  
   server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or di  
  rectory")    

I tried with container version (tag) 4.8.1 and everything works as intended

@blairlearn
Copy link

I've encountered what I believe is the same problem, using Docker 18.06.1-ce on Windows 10 (1709).

The underlying problem appears to be that mysql doesn't start automatically.

C:\> docker run --rm -it geerlingguy/drupal-vm /bin/bash
root@5f7ae573e64f:/# mysql -h localhost -u drupal -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

I've had some luck working around this by following these steps (offered with no warranty)

  1. map a volume to /var/lib/mysql
  2. start the container (I've been using docker-compose, see below)
  3. Use docker exec -it <container> /bin/bash
    1. /etc/init.d/mysql start
    2. mysql -h localhost -u drupal -p

At that point, I've been able to stop and restart the container and still have mysql come up. I'm not sure if/why it's necessary to login to mysql, but this only seems to work when that step is present.

One point that may or may not be significant is that I'm using docker-composer (based on the docker-compose.yml example in the drupal-vm docker instructions). Here's the relevant snippet:

version: "3.7"

services:
  drupal-vm:
    build:
      context: front-end
    container_name: drupal-web
    volumes:
      # SQL container
      - /var/lib/mysql

The "drupal-vm" service uses a Dockerfile which builds on top of geerlingguy/drupal-vm:latest.

@geerlingguy
Copy link
Owner

It sounds like for some reason the MySQL service isn't starting up properly. I'll have to take a look as to why that's the case.

@bioborg
Copy link

bioborg commented Nov 11, 2018

So, it looks like a systemd launch was attempted, but it failed? dbus isn't running?

f1c43a15f0b6 geerlingguy/drupal-vm "/lib/systemd/systemd" 7 minutes ago Up 7 minutes 0.0.0.0:80->80/tcp, 3306/tcp, 0.0.0.0:443->443/tcp, 8025/tcp drupalvm
root@DebFang:/home/fang/VMs# docker exec -it f1c43a15f0b6 /bin/bash
root@f1c43a15f0b6:/# /etc/init.d/mysql start
Failed to connect to bus: No such file or directory
[....] Starting mysql (via systemctl): mysql.serviceFailed to connect to bus: No such file or directory
failed!
root@f1c43a15f0b6:/# systemctl start mysql
Failed to connect to bus: No such file or directory

@bioborg
Copy link

bioborg commented Nov 12, 2018

so, when I followed dudes workaround, when copying the example.drupal-composer.yml file, I had to change the version to "2" to make it work.

@geerlingguy
Copy link
Owner

If it's a problem like 'Failed to connect to bus', then that means you might not be starting the container with the right volume mounts—see https://github.com/geerlingguy/drupal-vm/blob/master/example.docker-compose.yml#L30

@d70rr3s
Copy link

d70rr3s commented Jan 26, 2019

If it's a problem like 'Failed to connect to bus', then that means you might not be starting the container with the right volume mounts—see https://github.com/geerlingguy/drupal-vm/blob/master/example.docker-compose.yml#L30

Hi @geerlingguy I'm getting this error but when trying to bake a fresh image from the container. I've follow the instructions about the volumes but still not working. In my case I'm getting the error during provitioning when checking that POSTFIX service is started

TASK [geerlingguy.postfix : Ensure postfix is installed.]
**********************************************************
ok: [localhost]

TASK [geerlingguy.postfix : Update Postfix configuration.]
**********************************************************
ok: [localhost] => (item={u'name': u'inet_interfaces', u'value': u'localhost'})
ok: [localhost] => (item={u'name': u'inet_protocols', u'value': u'all'})

TASK [geerlingguy.postfix : Ensure postfix is started and enabled at boot.]
**********************************************************
fatal: [localhost]: FAILED! => {
"changed": false, 
"cmd": "/bin/systemctl", 
"msg": "Failed to connect to bus: No such file or directory", 
"rc": 1, 
"stderr": "Failed to connect to bus: No such file or directory\n", 
"stderr_lines": ["Failed to connect to bus: No such file or directory"], 
"stdout": "", "stdout_lines": []}
to retry, use: --limit @/etc/ansible/drupal-vm/provisioning/playbook.retry

PLAY RECAP *********************************************
localhost                  : ok=16   changed=0    unreachable=0    failed=1

Any advice?

@pwayner
Copy link

pwayner commented May 2, 2019

I'm getting a similar error using Docker on Ubuntu.


 // You are about to CREATE the 'drupal' database. Do you want to continue?:    
 // yes.                                                                        


In SiteInstallCommands.php line 367:
                                          
  Failed to drop or create the database:  
                                          

site:install [--db-url DB-URL] [--db-prefix DB-PREFIX] [--db-su DB-SU] [--db-su-pw DB-SU-PW] [--account-name [ACCOUNT-NAME]] [--account-mail [ACCOUNT-MAIL]] [--site-mail [SITE-MAIL]] [--account-pass ACCOUNT-PASS] [--locale [LOCALE]] [--site-name [SITE-NAME]] [--site-pass SITE-PASS] [--sites-subdir SITES-SUBDIR] [--config-dir CONFIG-DIR] [--existing-config] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify] [--druplicon] [--xh-link XH-LINK] [--] <command> [<profile>]...

@poindexterous
Copy link

I have this issue as well, I'm using "method 1" on the drupalvm docker installation docs:
http://docs.drupalvm.com/en/latest/other/docker/

` // You are about to CREATE the 'drupal' database. Do you want to continue?:
// yes.

In SiteInstallCommands.php line 367:

Failed to drop or create the database:

site:install [--db-url DB-URL] [--db-prefix DB-PREFIX] [--db-su DB-SU] [--db-su-pw DB-SU-PW] [--account-name [ACCOUNT-NAME]] [--account-mail [ACCOUNT-MAIL]] [--site-mail [SITE-MAIL]] [--account-pass ACCOUNT-PASS] [--locale [LOCALE]] [--site-name [SITE-NAME]] [--site-pass SITE-PASS] [--sites-subdir SITES-SUBDIR] [--config-dir CONFIG-DIR] [--existing-config] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--druplicon] [--notify] [--xh-link XH-LINK] [--] []...`

I wonder if this might be an issue with drush using site-install, the drush version seems to be 9.6.2. It does not appear as if the database creation step was successful. I'm also on a windows 10 environment.

@geerlingguy
Copy link
Owner

Quick fix is:

Inside the container (if you do docker exec -it [docker container name] bash), you can run systemctl start mysql and I believe that will get it running. It's a little bit difficult to figure that out because the Drush message doesn't really indicate the server's not running at all.

(Moved that comment from related issue #1937).

@gparami
Copy link
Contributor

gparami commented Sep 19, 2019

"Method 1" on the Drupal VM Docker installation docs will work if you add the volumes to the docker run command.
Use the following Docker run command and Drupal 8 should work:
docker run -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro -p 80:80 -p 443:443 --name=drupalvm --privileged geerlingguy/drupal-vm
docker exec drupalvm install-drupal 8.x-dev

you can choose a version using install-drupal [version], using versions like 8.x-dev or 7.x-dev

gparami added a commit to gparami/drupal-vm that referenced this issue Sep 19, 2019
Error: `In SiteInstallCommands.php line 367: Failed to drop or create the database:`
This is due because the `systemctl start mysql` command failed due to missing volume. Fix was to add the missing volume to the command.
Also, resolves geerlingguy#1856
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants