But I get an error AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message and - perhaps for the same reason - wordpress will not connect to mariadb when I load http://172.18.0.4
This script is the first and only one Iāve ever written and Iām devastated that it has stopped working because Docker is hard. Any clues on how to solve this.
Can you open the page and the db connection fail, or cant you open the wordpress at all?
The first thing that comes to mind, is that you have set wordpress to be available on port 8000, but you didnāt define a port in your request, it would be: http://172.18.0.4:8000
I use Docker so that I donāt have the whole LAMP stack running on my machine all the time (I normally just write javascript with webpack building). So the next thing I need to do is to prevent docker loading at boot time. Iām also wondering how the bootup scripts know where to find my docker script on the disk?
Then, these are the results of various urls
localhost:61112/ loads phpmyadmin
localhost:8000/ is automatically redirected to localhost which fails with localhost refused to connect.
172.20.0.4/ loads my wordpress site
172.19.0.3/ loads phpmyadmin
But these 172.*.*.* addresses are different every time I boot so I canāt work with them as, for example, the url gets hard coded into the wordpress database.
ā sudo docker version
Client: Docker Engine - Community
Version: 19.03.1
API version: 1.40
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:21:22 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.1
API version: 1.40 (minimum version 1.12)
Go version: go1.12.5
Git commit: 74b1e89
Built: Thu Jul 25 21:19:53 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc8
GitCommit: 425e105d5a03fabd737a126ad93d62a9eeede87f
docker-init:
Version: 0.18.0
GitCommit: fec3683
Your expectation, that containers should not be restarted after a system restart, contradicts with the ārestart: alwaysā policies in your docker-compose.yml
In the container world, accessing a container by its ip is in 99,99% of the cases wrong, as a container ip is not static and will eventualy change. For container to container communication the servicename (or an network alias or the containers hostname) needs to be used. If you want to access the service inside the container, you will need to publish a port and use it to access your containerized service.
There is no other direction than terpz and tekki already guided you to
Now the remaining question is: why is accessing wp using the url http://localhost:8000 not working. What sort of forward does the container do? You might want to share the snippet of the configuration that does the forwarding.
I will remove the restart line - Iām a complete amateur, but I know I donāt want docker running all the time because I use only very infrequently for one client.
I do not want to use IP addresses either, so the heart of my question is how to get localhost to be recognised as Docker starts.
I realise now that although I can get to the login screen of phpmyadmin, I cannot login at I get an error that mysql has gone away, presumably because of the weirdness in the IP address.
As regards 8000, I do not know of any other redirecting but that might - perhaps - be due to wordpress as it stores the siteās url in its DB. That would right itself if I could get a stable name for what docker is running.
I think that Apache is struggling to get its ServerName correctly, but I do not know how to tell Apache inside a container what this value should be. I tried some suggestions by logging into the container when it was running and changing apache.conf, but the changes did not survive a restart
Not sure what this is supposed to say - there is plenty of room for guessing in this sentence
How and where is the db configuration done in phpmyadmin? There is no environment varible present in your docker-compose.yml that would configure itā¦
Yep, the last one seems like a winner! If the port is part of the stored configuration, the hostname is NOT your problem. The problem is that the wp config expects itself under a given port, which is unknown in your hosts world.
Also i did find that people mention hard coded settings in the wp-config.php file.
You could try to set the āexternalā access url from the hosts perspective:
define(āWP_SITEURLā, āhttp://localhost:8080/ā);
define(āWP_HOMEā, āhttps://localhost:8080/ā);
If this doesnāt work - you could try to publish the container port to the same port on your host (this way http:/localhost:80 is valid on the host and in the container). Make sure the settings in wp-config.php do use port 80 as well.
If this is still insufficient, you could add a reverse proxy configuration in your wp container or put a reverse proxy in front that does url rewrite for you.
I uninstalled everything and ran rm -rf /var/lib/docker, then followed the instructions to use docker-compose without sudo.
As a result after running docker-compose up
http://localhost:61112 is now serving phpmyadmin
curl http://172.18.0.3 returns the initial page of a wordpress setup, but
curl http://localhost:8000 first got reset by host and then a while later a wordpress error page where the key line is php_network_getaddresses: getaddrinfo failed: Name or service not known. I get the same error with curl http://172.18.0.4
and in the logs as its starts up I still get
wordpress_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
I canāt help thinking that if I could fix this so that the reliable fqn was localhost I may be in a much better situation?
My sincere apologies - you can be absolutely certain that my intention was not to piss anyone off. I am at a complete loss for ideas why a brand new ubuntu 19.04 with a brand new docker and a script more or less cut and paste from the internet gets such intractable errors, but I know for certain that I wonāt be able to resolve them alone
it was intended to be sarcastic: think about your establish a chain of thoughts, and tell someone about doās and donātsā¦ and the next thing you see is that everything estables before is completly ignored. I am neither mad, nor pissed of - why should I? It is just a sign for me that I am not able to help you with your situation.
No worries then. Just found https://github.com/nezhar/wordpress-docker-compose/issues/19 and I have the same issue with this very popular script. That makes me think the issue is more to do with the interaction between docker and the network settings of my own box. On the latter, I did recently get a major update from my cable provider (new router etc)
And now tried this repo on a Mac on the same network and it worked fine, but with the apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message messages, so I realiae that those were indeed the source of the problem