mautic / docker-mautic

Docker Image for Mautic
https://www.mautic.org
382 stars 281 forks source link

mautic-web not allowed to connect to this MySQL server #262

Closed seljuck closed 9 months ago

seljuck commented 9 months ago

Hello,

I'm using the fpm-nginx example with the only change being I added an external reverse proxy network to the compose file. When I do "docker compose up -d" I get the following error over and over

mautic_web-1 | mysqladmin: connect to server at 'db' failed mautic_web-1 | error: 'Host '172.x.0.3' is not allowed to connect to this MySQL server'

I've added passwords for MySQL in the .env file.

Thanks

mollux commented 9 months ago

@seljuck that may indeed cause issues, as the current examples don't specify another network.

I created a PR to at least isolate the internal services, see https://github.com/mautic/docker-mautic/pull/266 Could you try that PR with rhe extra reverse proxy changes you did?

enejravbar commented 9 months ago

Hello Mautic team,

I can confirm issues with setting up Mautic5 containers with current configuration files found in the folders examples/basic and examples/fpm-nginx.

If we focus on basic Mautic configuration examples/basic, there is a problem with container _basic_mautic_web1 because it's not able to connect to MySQL DB (consequently health check fails, and the remaining containers are not created).

mysqladmin: connect to server at '' failed
error: 'Can't connect to server on 'localhost' (99)'
Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists!

image

Is there a way to prepare configuration files for both editions examples/basic & examples/fpm-nginx to work out-of-the-box (with default settings) on a fresh Ubuntu server (Ubuntu Server 22.04.3 LTS )?

Thanks in advance!

mollux commented 9 months ago

@enejravbar that's another issue, see e.g. the db server being empty in your example and filled in in the original post.

you're most likely using docker-compose (v1) instead of docker compose (v2) Can you retry using docker compose?

seljuck commented 9 months ago

@seljuck that may indeed cause issues, as the current examples don't specify another network.

I created a PR to at least isolate the internal services, see #266 Could you try that PR with rhe extra reverse proxy changes you did?

Hello Mollux,

This worked. I was able to add my Reverse Proxy Network, and the containers all started up. However when I go to the Mautic web page, I get stuck on checking the Databases. When I check the docker compose logs, the mautic-worker is filled with errors like this...

mautic_worker-1 | messenger:consume [-l|--limit LIMIT] [-f|--failure-limit FAILURE-LIMIT] [-m|--memory-limit MEMORY-LIMIT] [-t|--time-limit TIME-LIMIT] [--sleep SLEEP] [-b|--bus BUS] [--queues QUEUES] [--no-reset] [--] [...] mautic_worker-1 | mautic_worker-1 | mautic_worker-1 | 2024-02-19 20:56:56,574 WARN exited: messenger-consume-hit_01 (exit status 1; not expected) mautic_worker-1 | 2024-02-19 20:56:56,575 WARN exited: messenger-consume-email_00 (exit status 1; not expected) mautic_worker-1 | [OK] Consuming messages from transport "hit". mautic_worker-1 | mautic_worker-1 | 2024-02-19 20:56:56,580 INFO spawned: 'messenger-consume-email_00' with pid 42667 mautic_worker-1 | 2024-02-19 20:56:56,582 INFO spawned: 'messenger-consume-hit_01' with pid 42668 mautic_worker-1 | // The worker will automatically exit once it has received a stop signal via mautic_worker-1 | // the messenger:stop-workers command. mautic_worker-1 | mautic_worker-1 | // Quit the worker with CONTROL-C. mautic_worker-1 | mautic_worker-1 | // Re-run the command with a -vv option to see logs about consumed messages. mautic_worker-1 | mautic_worker-1 | mautic_worker-1 | In SyncTransport.php line 37: mautic_worker-1 | mautic_worker-1 | You cannot receive messages from the Messenger SyncTransport. mautic_worker-1 | mautic_worker-1 |

mollux commented 9 months ago

@seljuck that's because your Mautic isn't installed yet. Once you installed Mautic, those will stop.

But that's only a mitigation, so I made a PR for that too, see https://github.com/mautic/docker-mautic/pull/264 If you build the docker image based on that PR, you should be able to test it, see the steps in the PR.

mollux commented 9 months ago

@seljuck and for the database issue

However when I go to the Mautic web page, I get stuck on checking the Databases

can you show the exact error?

seljuck commented 9 months ago

@seljuck that's because your Mautic isn't installed yet. Once you installed Mautic, those will stop.

But that's only a mitigation, so I made a PR for that too, see #264 If you build the docker image based on that PR, you should be able to test it, see the steps in the PR.

I went to try the build and I get this error message

ERROR: "docker buildx build" requires exactly 1 argument. See 'docker buildx build --help'.

Usage: docker buildx build [OPTIONS] PATH | URL | -

Start a build

seljuck commented 9 months ago

@seljuck and for the database issue

However when I go to the Mautic web page, I get stuck on checking the Databases

can you show the exact error?

I just get a gateway 504 timeout error.

mollux commented 9 months ago

ERROR: "docker buildx build" requires exactly 1 argument. See 'docker buildx build --help'.

that's another command I specified, I's not needed to use the buildx capabilities.

can you try:

docker build -t mautic/mautic:5-apache --build-arg MAUTIC_VERSION=5.0.3 -f apache/Dockerfile
mollux commented 9 months ago

@seljuck my bad forgot the . at the end.

Can you try

docker build -t mautic/mautic:5-apache --build-arg MAUTIC_VERSION=5.0.3 -f apache/Dockerfile .
seljuck commented 9 months ago

Wait, I just realized. I'm using the fpm version. Will this build still work for me?

mollux commented 9 months ago

sure, use the following:

docker build -t mautic/mautic:5-fpm --build-arg MAUTIC_VERSION=5.0.3 -f fpm/Dockerfile .

seljuck commented 9 months ago

This is not working very well for me. As I was not using the full folder structure as listed here. I just copied the fpm example into my own folder, called mautic-test. So using the above build is getting an error when I run it.

mautic_web-1 | mysqladmin: connect to server at 'db' failed mautic_web-1 | error: 'Access denied for user 'mautic_db_user'@'192.168.32.3' (using password: YES)'

seljuck commented 9 months ago

The containers are waiting for the connection to the DB [+] Running 0/2 [+] Running 0/3nginx-docker Created 0.3s ⠇ Network fpm-nginx-docker Created 0.9s ⠧ Container fpm-nginx-db-1 Created 0.8s [+] Running 2/6m-nginx-mautic_web-1 Creating 0.5s ⠦ Network fpm-nginx-docker Created 294.7s ✔ Container fpm-nginx-db-1 Healthy 7.7s ⠸ Container fpm-nginx-mautic_web-1 Waiting 294.3s ✔ Container fpm-nginx-nginx-1 Started 8.2s ⠧ Container fpm-nginx-mautic_cron-1 Created 293.8s ⠧ Container fpm-nginx-mautic_worker-1 Created 293.8s

mollux commented 9 months ago

@seljuck could you please try the exact example, so we can rule out some local difference? Then you can work from there to figure out how you your own setup works, and let us know, so we can add en extra example or general explanation of such usecase

enejravbar commented 9 months ago

@enejravbar that's another issue, see e.g. the db server being empty in your example and filled in in the original post.

you're most likely using docker-compose (v1) instead of docker compose (v2) Can you retry using docker compose?

Hello @mollux,

thank you for your quick reply.

After navigating to the examples/basic folder and running sudo docker compose up -d (using compose v2) containers successfully started up.

Currently, I’m facing issues with accessing the Mautic web interface. The port 80 is not responding.

I tried to access it:

Firewall rules are OK (allowing all inbound traffic for ports 80, 443).

Here are logs that are repeatedly shown up.

2024-02-20 10:16:01 mautic_cron-1    | In Driver.php line 34:
2024-02-20 10:16:01 mautic_cron-1    |                                                     
2024-02-20 10:16:01 mautic_cron-1    |   SQLSTATE[HY000] [2002] No such file or directory  
2024-02-20 10:16:01 mautic_cron-1    |                                                     
2024-02-20 10:16:01 mautic_cron-1    | 
2024-02-20 10:16:01 mautic_cron-1    | 
2024-02-20 10:16:01 mautic_cron-1    | In ConnectionFactory.php line 183:
2024-02-20 10:16:01 mautic_cron-1    |                                                                                
2024-02-20 10:16:01 mautic_cron-1    |   An exception occurred while establishing a connection to figure out your pl  
2024-02-20 10:16:01 mautic_cron-1    |   atform version.                                                              
2024-02-20 10:16:01 mautic_cron-1    |   You can circumvent this by setting a 'server_version' configuration value    
2024-02-20 10:16:01 mautic_cron-1    |                                                                                
2024-02-20 10:16:01 mautic_cron-1    |   For further information have a look at:                                      
2024-02-20 10:16:01 mautic_cron-1    |   https://github.com/doctrine/DoctrineBundle/issues/673                        
2024-02-20 10:16:01 mautic_cron-1    |                                                                                
2024-02-20 10:16:01 mautic_cron-1    | 
2024-02-20 10:16:01 mautic_cron-1    | In ExceptionConverter.php line 101:
2024-02-20 10:16:01 mautic_cron-1    |                                                                                
2024-02-20 10:16:01 mautic_cron-1    |   An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or  
2024-02-20 10:16:01 mautic_cron-1    |    directory                                                                   
2024-02-20 10:16:01 mautic_cron-1    |                                                                                
2024-02-20 10:16:01 mautic_cron-1    | 
2024-02-20 10:16:01 mautic_cron-1    | In Exception.php line 28:
2024-02-20 10:16:01 mautic_cron-1    |                                                     
2024-02-20 10:16:01 mautic_cron-1    |   SQLSTATE[HY000] [2002] No such file or directory  
2024-02-20 10:16:01 mautic_cron-1    |                                                     
2024-02-20 10:16:01 mautic_cron-1    | 
2024-02-20 10:16:01 mautic_cron-1    | In Driver.php line 34:
2024-02-20 10:16:01 mautic_cron-1    |                                                     
2024-02-20 10:16:01 mautic_cron-1    |   SQLSTATE[HY000] [2002] No such file or directory  
2024-02-20 10:16:01 mautic_cron-1    |                                                     
2024-02-20 10:16:01 mautic_cron-1    | 
2024-02-20 10:16:03 mautic_web-1     | 127.0.0.1 - - [20/Feb/2024:09:16:03 +0000] "GET / HTTP/1.1" 302 648 "-" "curl/7.88.1"
2024-02-20 10:16:08 mautic_web-1     | 127.0.0.1 - - [20/Feb/2024:09:16:08 +0000] "GET / HTTP/1.1" 302 648 "-" "curl/7.88.1"
2024-02-20 10:16:13 mautic_web-1     | 127.0.0.1 - - [20/Feb/2024:09:16:13 +0000] "GET / HTTP/1.1" 302 648 "-" "curl/7.88.1"
2024-02-20 10:16:18 mautic_web-1     | 127.0.0.1 - - [20/Feb/2024:09:16:18 +0000] "GET / HTTP/1.1" 302 648 "-" "curl/7.88.1"
2024-02-20 10:16:23 mautic_web-1     | 127.0.0.1 - - [20/Feb/2024:09:16:23 +0000] "GET / HTTP/1.1" 302 648 "-" "curl/7.88.1"

Do you have any idea what might be an issue?

Thanks in advance!

seljuck commented 9 months ago

@seljuck could you please try the exact example, so we can rule out some local difference? Then you can work from there to figure out how you your own setup works, and let us know, so we can add en extra example or general explanation of such usecase

I did a git clone into a new folder. Used the build command above. I didn't setup my reverse proxy network. Just used the default docker-compose.yml and .env settings from the fpm-nginx example.

When I do docker compose up -d I'm still getting the same error.

mautic_web-1 | mysqladmin: connect to server at 'db' failed mautic_web-1 | error: 'Access denied for user 'mautic_db_user'@'192.168.48.3' (using password: YES)'

seljuck commented 9 months ago

@mollux Could it be trying to use the Database from my initial docker-compose run?

Also, you asked on slack, if I have any other projects with a container named db? Yes, I do. A Nextcloud instance.

back-2-95 commented 8 months ago

@enejravbar did you get it working? I have the problem with accessing port 80 of web worker but I have db connection working fine.

seljuck commented 8 months ago

If you use build a container using @mollux advice, you can get it all to work. But I'm waiting for the official Docker Container to be updated with those settings.

back-2-95 commented 8 months ago

Hmm.. update (I use apache examples/basic version):

I cannot see from the discussion what settings are getting in if building the Docker image manually?