WordPress Docker Image breaks REST api because loopback fails [closed]


Posted this originally on the wordpress.org forums but the only response was to post in the #core-restapi slack channel. I did that and someone from their suggested I post here.

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 to port 80 of 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
  • Docker engine 19.03.8
  • Compose 1.25.4
  • macOS catalina 10.15.3

Thanks for any help!

, kerrykimrusso 3 years 2020-04-06T16:52:26-05:00 0 Answers 147 views 1

Leave an answer