i tried to install my first wordpress with docker but everytime i compose it in yml file like docker-compose up . it says mysql no route to host .
some error is
[07-Mar-2020 13:38:16 UTC] PHP Warning: mysqli::__construct(): (HY000/2002): No route to host in Standard input code on line 22
"WARNING: unable to establish a database connection to 'db:3306'"
continuing anyways (which might have unexpected results)
AH00558: apache2: Could not reliably determine the servers fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
Where address is the network ip where your docker containers are running.
Moreover, i need to change the wordpress config.php file to:
/** MySQL hostname */
define( âDB_HOSTâ, â172.17.0.1:3306â );
Where the ip address is the ip of the gateway of the network where the containers are running!!!
So, this work. I was able to run the wordpress and configure the website. But i think that i cant have connection inside the wordpress container to the internet. I think this, because in same pages, should show some content from wordpress server and donât show anything. show a error. Moreover, when cant import some content from internet sources.
I thinking to change my OS to centos7 to see if this is some problem of the OS
First i enter as root on the host, and them perform the command. Look to the image. iâm in [root@localhost], in this way i donât need to âsuâ or âsudoâ
I really donât know why you are getting that error. you can try to turn off your firewall to test.
sudo systemctl disable firewalld
This work to have DNS in the container.
EDIT: try to see if you have any typo in the command
You will get the error when you run docker-compose up.
Try do this:
docker-compose up -d
this will run the containers in detach mode.
After that, go to the volume where are the wordpress files and look for the wp-config.php file (see image bellow)
open the file, look for the
/** MySQL hostname */
define( âDB_HOSTâ, âdb:3306â);
and change for
define( âDB_HOSTâ, â172.17.0.1:3306â );
The ip, is the gateway ip from the network where the container is running. You need to verify what is in your docker.
This is a workaround, this is not a definitive solution, you probably will need to change this ip if you stop your containers or if you change the containers network. in the same way you will need to change and run the firewall command.
well⊠i will put here my docker-compose file. I have some things commented due to some debugging. I was able to put the this working using this yml file and the procedures explained before.
Last comment here. I found the problem and the solution.
Problem: Centos 8 firewall
Best Solution: add the docker networks/interfaces to a trusted zone.
In the host:
1: Find the network interfaces used by docker - run the command:
nmcli
and will show all network interfaces in the computer. The docker interfaces are: docker0 and br-xxxxxxxx (i think that depends on how many networks you have in the cluster)
For me, was 3 networks.
2- Add all interfaces to trusted zone with the command: