Docker Community Forums

Share and learn in the Docker community.

WordPress Docker Image breaks REST api because loopback fails

I originally posted this on the wordpress.org forums without realizing that this official image is created by Docker and not by Wordpress. If there is a better place to post this to get support for a specific image please let me know.

My setup (so far) uses docker swarm to run the wordpress:5.4.0-apache image networked with a msyql:5.7.29 image for the database. I copied the docker-compose file from the readme on the docker image page. It maps port 8080 on the host port 80 for the wordpress container. The issue seems to be that this breaks the REST API since it will try to hit localhost:8080 inside the container rather than localhost:80. WordPress reports this in the Tools > Site Health section of the dashboard as a critical error:

cURL error 7: Failed to connect to localhost port 8080: Connection refused

If I change the port mapping to expose 80 to the host, then everything works as expected.

Is there a Docker only workaround so that I can expose any port I want to the host and still have the loopback call work? Or would any solution require changes to wp-config.php or some other wp file?

If this is a limitation of using wordpress with docker, then the documentation needs to fix the error in the docker-compose file and make a note of this limitation. Or if there is a way to use a different port successfully, then that should be documented.

Other system details:
– Docker for mac 2.2.0.4
– Docker engine 19.03.8
– Compose 1.25.4
– macOS catalina 10.15.3

Thanks for any help!