nezhar / wordpress-docker-compose

Easy Wordpress development with Docker and Docker Compose
MIT License
1.84k stars 1.31k forks source link

How can I run more than one instance? #31

Closed palomnik closed 5 years ago

palomnik commented 5 years ago

I am trying to figure out how to run more than one instance, but have not been able to get it to work.

I set ${IP}:8000:80 for instance 1 and tried ${IP}:8010:80 I increased the other port numbers (db and pma) by one.

If I take one instance down, I can run the other one, but not at the same time. What do I need to configure to run both on different ports?

remach commented 5 years ago

Hi, Could you please describe more details, what happens when you up the second stack? (http response, log, dmesg )

palomnik commented 5 years ago

OK I solved the problem.

I incremented all external port numbers in the docker-compose.yml. That worked and got me pma at least, but I had the problem that when opening the second site it forwarded to the first site. Since the site had already existed on port 8000, I went into pma and changed the URLs in options - first duh!

It still forwarded from 8010 to 8000. I couldn't think of anywhere else the port would be referenced on the second site, but I decided to create a fresh site from scratch. It still forwarded. Then I opened a different browser and it worked. I cleared my browser cache, which I had forgotten to do, and it worked - second duh!

So all it takes is to bring up a new site by incrementing the external port numbers. I ought to work on this so that I can bring up a second instance without recreating containers for db and pma, since it is just unecessary overhead, but that is not a priority now.

My next problem to solve will be to add mailhog and some way for WP to send mail so that I can test mail sending.

Mailhog is easy enough - I just add:

mailhog: image: mailhog/mailhog ports:

But WP needs an SMTP server to use it, I think. I will research adding something like msmtp. If you have already figured that out, please let me know!

palomnik commented 5 years ago

OK, so I should not have posted an add-on issue, but I solved that one too. The method described on this page works and is easy to implement:

https://gist.github.com/eduwass/039864b7dca85f06c3883b6fab0f7f2e

Just add the mailhog as above (I reverted back to using port 1025) to the YML file and then add a snippet of code on the page to the functions.php or another code snippet plugin - mail can be tested easily.

nezhar commented 5 years ago

You can do it either by changing the ports or by changing the IP address. And yeah, you have to make sure that this corresponds to your WordPress configuration that is stored in the Database or you can overwrite it in the wp-config.php:

define('WP_HOME','http://127.0.0.10');
define('WP_SITEURL','http://127.0.0.10');

Thanks for sharing your gist :slightly_smiling_face: This is definitely useful when developing and sending mails.