ever-co / ever-traduora

Ever® Traduora™ - Open Translation Management Platform - https://traduora.co
https://traduora.co
GNU Affero General Public License v3.0
1.97k stars 197 forks source link

Macos: Running Docker container fails to connect to database #405

Closed ncul777 closed 3 months ago

ncul777 commented 3 months ago

Describe the bug Trying to run the docker container however it fails to connect to the mysql database

To Reproduce Steps to reproduce the behavior:

  1. Download the container https://hub.docker.com/r/everco/ever-traduora
  2. Run brew install mysql
  3. Run from docker desktop
  4. See error
[Nest] 1  - 04/25/2024, 10:14:35 AM   ERROR [ExceptionHandler] connect ECONNREFUSED 127.0.0.1:3306
2024-04-25 11:14:35 Error: connect ECONNREFUSED 127.0.0.1:3306
2024-04-25 11:14:35     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
2024-04-25 11:14:35     --------------------
2024-04-25 11:14:35     at Protocol._enqueue (/opt/traduora/node_modules/mysql/lib/protocol/Protocol.js:144:48)
2024-04-25 11:14:35     at Protocol.handshake (/opt/traduora/node_modules/mysql/lib/protocol/Protocol.js:51:23)
2024-04-25 11:14:35     at PoolConnection.connect (/opt/traduora/node_modules/mysql/lib/Connection.js:116:18)
2024-04-25 11:14:35     at Pool.getConnection (/opt/traduora/node_modules/mysql/lib/Pool.js:48:16)
2024-04-25 11:14:35     at /opt/traduora/node_modules/typeorm/driver/mysql/MysqlDriver.js:841:18
2024-04-25 11:14:35     at new Promise (<anonymous>)
2024-04-25 11:14:35     at MysqlDriver.createPool (/opt/traduora/node_modules/typeorm/driver/mysql/MysqlDriver.js:838:16)
2024-04-25 11:14:35     at MysqlDriver.<anonymous> (/opt/traduora/node_modules/typeorm/driver/mysql/MysqlDriver.js:284:51)
2024-04-25 11:14:35     at step (/opt/traduora/node_modules/typeorm/node_modules/tslib/tslib.js:143:27)
2024-04-25 11:14:35     at Object.next (/opt/traduora/node_modules/typeorm/node_modules/tslib/tslib.js:124:57)

Expected behavior The container runs, connects to the db and I can access the UI.

Environment (please complete the following information):

Additional context A possible solution could be to use host.docker.internal instead of localhost or 127.0.0.1 See https://stackoverflow.com/a/43541681

Running docker-compose up works fine as it downloads the mysql container

evereq commented 3 months ago

@culliard sorry but if you just run docker container separately with Traduora backend, it means you need to make sure your MySQL is started before that. Did you checked that MySQL is running locally? According to https://stackoverflow.com/questions/4359131/brew-install-mysql-on-macos on Mac OS you may get "MySQL server might not be running after installation with Brew. Try brew services start mysql or just mysql.server start if you don't want MySQL to run as a background service." etc.

ncul777 commented 3 months ago

My MySQL was started fine.

Running docker run -d -p 8080:8080 --name traduora everco/ever-traduora:latest it did not work. There could be detailed info about running traduora with mysql in this case. Ideally also test it on a macbook.

In my opinion issue is not closed, although maybe low priority as there are other ways to get it running.

evereq commented 3 months ago

Maybe MySQL started fine, but did not bind to 127.0.0.1:3306, which is expected by Traduora to connect to by default I think... You can control host of DB with TR_DB_HOST env var, we should have it somewhere in docs :)