• 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!

    • This topic was modified 4 years, 6 months ago by kerrykimrusso.
Viewing 9 replies - 1 through 9 (of 9 total)
  • You can join the WordPress Slack here:

    Slack


    The channel is #core-restapi

    You may be asked to open a ticket on Core Trac from there.

    Thread Starter kerrykimrusso

    (@jooniya)

    Thank you for your response, but the slack channel seems to be reserved for contributors and not support questions

    Slack communication is used for contributing to the WordPress project, be it code, design, documentation, etc….

    Please note that there is no support channel for WordPress on Slack. The best place to get support is the www.ads-software.com support forums which are highly active and well maintained.

    I can take a look at their IRC channel, though they state the best place for support is the forums.

    Yes, Slack is reserved for contributing to the WordPress project.
    However, for the REST API specifically, only a handful of people can determine if it is necessary to update the documentation / whether it is something that the team may want to take on in terms of development and they are available during office hours.

    Thread Starter kerrykimrusso

    (@jooniya)

    Posted my question in the #core-restapi slack channel and they directed me to the forums or the wordpress stack exchange so I posted my question there as well: https://wordpress.stackexchange.com/questions/363381/wordpress-docker-image-breaks-rest-api-because-loopback-fails

    Jip. The person who answered you on Slack is one of the people who maintain the REST API, so they have solid judgement when it comes to this.

    The question is a bit specialized for the forums though. The question will remain here in case someone comes along that can help, but you might have better luck on StackExchange for this.

    Will hold thumbs ??

    The docker image you linked to isn’t an official WP docker image, it’s and maintained by Docker themselves without official involvement. You should report to them that they’re missing the loopback, or, update your own docker file to add the domain to the hosts file inside the container

    https://hub.docker.com/_/wordpress

    Thread Starter kerrykimrusso

    (@jooniya)

    @carike ty for your help

    @tjnowell I didn’t realize that. I’ll take this issue up with them then. Also, unless I’m thinking about this incorrectly, this is a port issue so aliasing a domain in the hosts file wouldn’t work in this situation. ty for your reply.

    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?

    I encountered something similar, and after MUCH searching and experimenting, I stumbled upon this post, which solved the issue for me. Maybe it will provide some insights for your situation.

    Thank you @digitaltech – this is very useful.

    No specific solution here but a good read, may help as well: https://github.com/docker-library/wordpress/issues/493

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WordPress Docker Image breaks REST api because loopback fails’ is closed to new replies.