0

This question is different than other similar questions because it involves running in a Docker container on OS X , which has previously been running fine for a week, and is now failing.

Following the instructions here:

https://medium.com/@tatemz/local-wordpress-development-with-docker-3-easy-steps-a7c375366b9

I was able to get a local WordPress install up and running very quickly and it's been wonderful.

Today when I start it up, there is a connection refusal that looks like it would be very simple to address if I could figure out two things from the following error messages:

MySQL Connection Error: (1130) Host '172.19.0.3' is not allowed to connect to this MariaDB server
Warning: mysqli::mysqli(): (HY000/1130): Host '172.19.0.3' is not allowed to connect to this MariaDB server in - on line 22

The 2 things I need to figure out are:

  1. "line 22" in what file? Is this a config file? What is the file name?
  2. On a Mac/Docker deployment like this, what is the path to this file?

The docker container directory only contains a WordPress install directory. There doesn't appear to be anything related to MySQL/MariaDB in that directory. I've read through a lot of documentation on Mac deployments of MySQL and where the config files would live, but being in a Docker container this is a different beast. The documentation I have found does not apply.

I have looked into SSH'ing into a Docker container (I'm a baby at Docker) but I don't even know if that's a thing you do.

Rjak
  • 2,097
  • 4
  • 19
  • 24
  • Possible duplicate of [Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server](https://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server) – miken32 May 25 '17 at 18:56
  • @miken32 The difference is that question does not involve Docker containers. I read the answers there and none of them lead me to finding these files or really even understanding the problem. – Rjak May 25 '17 at 21:00

1 Answers1

1

Your issue is probably with the MySQL container starting before the WordPress container. Try adding the depends_on tag to your docker-compose.yml file and remove the links tag. You also want to add restart: always to both containers.

  my-wp:
    image: wordpress
    volumes:
      - ./:/var/www/html
    depends_on:
      - my-wpdb
    restart: always
    ports:
      - "8080:80"
    environment:
      WORDPRESS_DB_PASSWORD: ChangeMeIfYouWant

You can take a look at your error logs by running:

docker logs -f CONTAINERNAME >/dev/null

If you want to open up a shell inside your container, you can run:

docker exec -ti CONTAINERNAME /bin/bash 
Thien Hoang
  • 331
  • 2
  • 4
  • Thanks @THN! Adding the depends_on did not fix the problem, but thank you for describing how to start a shell. I was able to find the MySQL my.cnf file once I had a shell and I found a section that mentions that the default is to listen on localhost only. There is a commented out line "#bind-address = 127.0.0.1" Apparently vi is not available inside the container so I cannot edit the file. My inclination would be to set the bind address to 0.0.0.0, but that would not explain why this setup has been working for a week and suddenly stopped. Any idea how I can edit this file? – Rjak May 25 '17 at 21:09
  • I installed vim in the container and edited the file and tried bind addresses 0.0.0.0 and 127.0.0.1. Setting to 127.0.0.1 predictably failed with a connection refusal ... makes perfect sense. Setting to 0.0.0.0 allowed the connection attempt, but the fact that the connecting IP is disallowed means there's still some piece refusing to allow the connection for security reasons. Still analyzing... – Rjak May 25 '17 at 21:16
  • Can you paste your entire docker-compose.yml file? I don't think it's an issue with the MySQL configuration. I didn't read the entire tutorial article you posted, but I suspect there's something outdated there. You should try setting up WordPress using the official Docker documentation for WordPress here: https://docs.docker.com/compose/wordpress/ – Thien Hoang May 25 '17 at 21:19