1

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.

enter image description here

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 5

4

you need to add the ip address from docker just need to see the logs in docker;

docker-compose logs -f
wordpress_1  | 172.23.0.1 - - [25/Jul/2021:14:39:19 +0000] "POST /wp-admin/admin-ajax.php HTTP/1.1" 200 609

find your IP address and then write it inside the docker-compose file:

wordpress:
  image: docker.io/bitnami/wordpress:5
  extra_hosts:
    - localhost:172.23.0.1
1

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

0

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 :

wordpress:
     image: wordpress:latest
     ports:
       - "8088:80"
     volumes:
       - ./app:/var/www/html

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.

0

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

0

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.

networks:
  wordpress-net:
    ipam:
      config:
        - subnet: 10.0.1.0/24
    driver: bridge

Now with that definition you set known static ips for the containers.

For the webserver:

  webserver:
    depends_on:
      - wordpress
    image: nginx:1.15.12-alpine
    container_name: webserver
    ports:
      - "80:80"
      - "443:443"
    networks:
      wordpress-net:
        ipv4_address: 10.0.1.2

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.

  wordpress:

    extra_hosts:
      - DOMAINNAME:10.0.1.2

    networks:
      wordpress-net:
        ipv4_address: 10.0.1.3

Change DOMAINNAME for your domain. Regards

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.