I have a simlpe wordpress website running in the docker container on top of Mac OS. When I try to run the Simply static plugin, its not working at all. I could not see any logs. The diagnostic section shows as the following one failed.
Checking if WordPress can make requests to itself from 172.20.0.3 X FAIL
I started the containers using the docker-compose as described here – https://docs.docker.com/samples/wordpress/
What am I missing here? I really want to generate the static version of my site.
Any helps is appreciated.
I already tried the suggested fix here and this not workin for me.
Regards,
Shamran.
5
Answers
you need to add the ip address from docker
just need to see the logs in docker;
find your IP address and then write it inside the docker-compose file:
In my situation the problem was the port mapping.
I was mapping 8080:80, so the WordPress was technically hosted on 80 inside the container, but the Url was defined to localhost:8080 (wordpress), making it unreachable by the container.
Solution:
Use port mapping 80:80
You can modify WordPress site URL to use the Docker container IP address and access it at http://172.20.0.3/wp-admin. The container will then be able to communicate with itself on port 80.
The problem is the Docker container cannot communicate with another port than the one assigned for the Web server. E.g. The container is created with the following mapping :
I have installed WordPress using http://0.0.0.0:8088, thus setting the site URL as so. Within the container, it is not possible to access localhost:8088 but only localhost:80. Setting the site URL with the container public IP allow internal communication to port 80 using the IP address.
I am using Automated Nginx reverse proxy for docker containers and I had the same problem. Although Simply Static said that ‘Checking if WordPress can make requests to itself from 192.168.112.2’ was 200 OK – it couldnt create the static files, it was no errors, no response, just blank Generate page.
I can confirm that ‘extra_hosts’ directive in docker-compose solved the issue.
Here is a screenshot of my docker-compose file
The problem is in the networking of your compose.
Wordpress needs to resolve the domain correctly or it will try with the localhost ip.
For this, it is best to define the subnet where the containers are located explicitly.
Now with that definition you set known static ips for the containers.
For the webserver:
At this point it is possible to reference the domain you are using with an extra_hosts directive, so that the wordpress machine knows how to resolve the domain.
Change DOMAINNAME for your domain.
Regards