mailtrain icon indicating copy to clipboard operation
mailtrain copied to clipboard

(v2) mailtrain won't connect to mysql when running via docker-compose

Open avataylor94 opened this issue 3 years ago • 4 comments

when bringing up the service via docker-compose,

i see the following on mysql's logs

mysql        | 2020-10-26  8:27:05 8 [Warning] Aborted connection 8 to db: 'unconnected' user: 'unauthenticated' host: '172.18.0.3' (This connection closed normally without authentication

mailtrain logs the following

mailtrain    | ERR! Queue/45 Could not initialize database: connect ECONNREFUSED 172.18.0.2:27017
mailtrain    | ERR! Child/default/45 [3f83045e93a7d158cafa] Sender process for default exited with 1

From a shell in the mailtrain instance

docker exec -it mailtrain bash

installed a mysql client

apk add mysql mariadb-client

connected via the client

mysql -h mysql -u mailtrain -pmailtrain 

seemed to work just fine

avataylor94 avatar Oct 26 '20 09:10 avataylor94

@avataylor94 Have you found a solution for this? Same problem here.

taenzerme avatar Nov 24 '20 13:11 taenzerme

It would make backups so much easier, if I could use the locally installed mariaDB, which has already some backup-scripts.

saschafoerster avatar Nov 24 '20 13:11 saschafoerster

I found a solution and will post the fixed configuration for the docker-compose.yml and the Mailtrain config file. Basically, the hostnames used in the default config (default.yaml: localhost, 127.0.0.1) don't work. Linking the containers in docker-compose to the mailtrain container and using the container names in the config file works.

taenzerme avatar Nov 24 '20 13:11 taenzerme

I was previously able to run mailtrain with just docker compose up, but after stopping and restarting with no configuration changes I now also encounter this issue. I have the URL_BASE_TRUSTED, URL_BASE_SANDBOX and URL_BASE_PUBLIC variables set. Adding "depends_on" from taenzerme's pull request did not change the behavior.

minosimo avatar Dec 26 '23 13:12 minosimo

We are going to start with the development and testing of mailtrain v3 in the next weeks.

You are welcome to help us with the testing as soon as the first release candidate is available.

talheim-it avatar Mar 16 '24 09:03 talheim-it