nezhar/wordpress-docker-compose

IP addresses got messed up

flip111 opened this issue · 4 comments

The first time i did docker-compose up i saw the address http://172.18.0.3 in the log so i browsed to there (before i went to 127.0.0.1). Also http://172.18.0.4, one for phpMyAdmin and the other one for the website.

Then i restarted my laptop and did docker compose again. Now the following situation:

  • Website on http://172.18.0.4/ tries to load assets from http://172.18.0.3/
  • http://172.18.0.3/ runs phpMyAdmin
  • http://127.0.0.1/ also tries to load assets from http://172.18.0.3/

I think this happened because i initially launched the website from http://172.18.0.3/ then this ip address got saved somewhere inside of the container (possible some wordpress config thing).

Now when i started the container it keeps trying to load css from http://172.18.0.3/. Sometimes wordpress will go to http://172.18.0.3/ other times i will go to http://172.18.0.4/. It switches around with phpMyAdmin. So my temporary workaround is that i just restart all and hope that it lands on the ip address where it's trying to load css from.

How can i get the css to load from http://localhost/ ? this would really fix the problem

@flip111 Your theory might be very much correct :) WordPress has one (possibly two, I don't remember exactly) settings in its database, where it stores the base URL of the website.

If your theory is correct, all you need to do is open the database, go to the settings table, search for and find settings with "172.18" in them, and edit the ones that make sense.

Since you can access the website on that IP, you could try to go to the admin panel of the website and change the settings there. But that only works if the website is actually working - I'd just do it in the database manually.

Here's a more complete reference on how to change these things: https://wpbeaches.com/updating-wordpress-mysql-database-after-moving-to-a-new-url/

Thanks a lot @rawtaz

I followed these 3 steps and now the problems is fixed

  1. Login to WordPress admin dashboard
  2. Click on Settings >> General
  3. Fill in your WordPress Address and Site Address and click Save.

I filled there http://127.0.0.1 in both fields.