Hi!
I was running Docker Desktop Community 2.2.0.4. I updated to the latest version (Docker Desktop Community 2.4.0.0) and enabled WSL2.
Then run my docker-compose.yml and everything was ok although I was having some performance issues with WSL2. Then, I decided to go back to WSL1 (due to those performance issues) disactivating WSL2 in the control panel, restarted Docker and I’m getting now the following message and can’t enable my database (mariadb):
Warning: mysqli::__construct(): (HY000/2002): Connection refused in /makedb.php on line 20
Call Stack:
0.0002 401576 1. {main}() /makedb.php:0
15.0062 403288 2. mysqli->__construct() /makedb.php:20
I tried to restart my computer but the problem remains.
If I go back to WSL2, this is issue is not happening. I’m a bit lost here.
Can anyone help me on this? Thank you in advance. Regards.
After running docker-compose up I get “mariadb 09:34:33.35 INFO ==> Starting mariadb in background” and then when my web app tries to connect to the db it shows:
“Warning: mysqli::__construct(): (HY000/2002): Connection refused in /makedb.php on line 20”
I remember upgrading once from Docker Desktop Community 2.2.0.4 to 2.2.0.5 and got a similar error. That’s why I kept 2.2.0.4 for a while.
Yesterday I updated from 2.2.0.4 to the latest stable (2.4.0.0) and got this issue when running through Hyper-V (with Wsl2 activated all is working just fine although the performance is a lot worse).
Now we can see what you are doing (in general it’s a good idea to show such things from the beginning). Your problem seems to be related to the Windows folder that you mount into the database container. On Windows, you better use a named volume, especially with WSL1.
Is there a reason that you don’t use the official MariaDB image?
I’m using a windows folder because a few months ago I lost my database (I was using a named volume). So I decided to map it to my windows file system to be able to run regular backups just in case I mess with it again.
Do you know if I can easily transfer the database files from my windows file system to a docker named volume?
How can I run backups on named volumes?
Note: I’M not using the official MariaDB image because when I lost the database a few month ago, I though MariaDB official image was the reason and switched to Bitnami.
You can copy the content of a volume into a zip file as described here. With the volume of the above example this would be something like
docker container run --rm -v dbdata:/dbdata -v $(pwd):/backup debian tar cvf /backup/backup.tar /dbdata
But first you have to stop the database before you do this. And second this is not the way to create a reliable database backup. Instead you should use the mysqldump command to create your backup files.