ElkArte Community

General => Chit Chat => Topic started by: emanuele on January 17, 2024, 04:21:50 pm

Title: Docker, mysql, apache and connection
Post by: emanuele on January 17, 2024, 04:21:50 pm
Hey all!
I've finally found some time to set up a NAS-like Frankenstein and I slapped on it unraid for testing it and see if it fits with what I had in mind.
And so I started immediately trying php and mysql to finally set up again a place I could use to develop some code (scared, right? :D ).
Though, I'm facing a bit of a problem with docker (that I'm quite the noob about) and can't understand most of the instructions I find on line... :joy:

So, I'm running unraid and installed 3 docker containers:
# ApachePHP8 (192.168.1.250 <-> 192.168.1.250)
# MariaDB (172.17.0.3 <-> 192.168.1.136)
# phpmyadmin (172.17.0.2 <-> 192.168.1.136)

The latest two talk happily and I can access the db from phpmyadmin, though the apachephp one doesn't connect to mariadb.
The only thing that differs are the IPs, mariadb and phpmyadmin have the same IP 192.168.1.136 and work on different ports, while the apachephp has its own 192.168.1.250.
Could it be that this is the issue?
Any idea how to convince mariadb docker to accept connections from php?
Title: Re: Docker, mysql, apache and connection
Post by: tino on January 17, 2024, 05:01:50 pm
You can set up an internal docker lan.

https://docs.docker.com/compose/networking/

Or do links both are described on that link.

The issue is that they’re not all on the 172.x.x.x lan
Title: Re: Docker, mysql, apache and connection
Post by: Spuds on January 17, 2024, 06:13:26 pm
This may help ... https://github.com/Spuds/Docker-ElkArte/tree/php82

Look at the docker-compose.yml to see how to connect things together. 

Title: Re: Docker, mysql, apache and connection
Post by: Spuds on January 17, 2024, 06:47:03 pm
I should note, in that setup the  $db_server  would be :drum:  db  that is what you would use in something like Settings.php
when to use adminer you would navigate to 123.123.123.123:8080
and sphinx server would be :drum:  sphinx
and mailhog (a way to test smtp) would be at 123.123.123.123:8025 and you would setup the mail server as 123.123.123.123 port 1025 in the ACP
Title: Re: Docker, mysql, apache and connection
Post by: emanuele on January 18, 2024, 03:28:38 pm
Well... I did what I'm best at doing: I screwed up everything and had to restart from zero. :joy:

then, I realized the only issue was I used entirely different networks when I should have just used the same and set different IPs.
Well, me and networks are not exactly friends. :D