You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the "Using Docker Compose" section of the tutorial, when I run the docker compose up -d command, the app fails to launch (i.e. nothing is reachable at http://localhost:3000/.
Examining the logs with docker compose logs -f I found the following error message:
app-mysql-1 | 2023-08-02T04:02:25.964656Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
and when I relaunched the app by saving a file again so nodemon relaunched the app, it worked fine:
app-app-1 | [nodemon] restarting due to changes...
app-app-1 | [nodemon] starting `node src/index.js`
app-app-1 | Waiting for mysql:3306.
app-app-1 | Connected!
app-app-1 | Connected to mysql db at host mysql
app-app-1 | Listening on port 3000
I suspect that the issue is related to this change #331 adding a timeout to the MySQL database connection.
There is actually a "Pro tip" in the tutorial about the app waiting for the database connection.
Pro tip - Waiting for the DB before starting the app
When the app is starting up, it actually sits and waits for MySQL to be up and ready before trying to connect to it. Docker doesn't have any built-in support to wait for another container to be fully up, running, and ready before starting another container. For Node-based projects, you can use the wait-port dependency. Similar projects exist for other languages/frameworks.
The text was updated successfully, but these errors were encountered:
In the "Using Docker Compose" section of the tutorial, when I run the
docker compose up -d
command, the app fails to launch (i.e. nothing is reachable athttp://localhost:3000/
.Examining the logs with
docker compose logs -f
I found the following error message:Further down in the logs, I saw this line:
and when I relaunched the app by saving a file again so
nodemon
relaunched the app, it worked fine:I suspect that the issue is related to this change #331 adding a timeout to the MySQL database connection.
There is actually a "Pro tip" in the tutorial about the app waiting for the database connection.
The text was updated successfully, but these errors were encountered: