Using Docker Compose example database connection timeout
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- docker-compose, javascript, mysql, node.js
- Área
- databases, devops, documentation
Línea de trabajo
Start with the tutorial's "Using Docker Compose" section and the app startup behavior shown in the docker compose logs. Reproduce the timeout with docker compose up -d, inspect the existing database-waiting setup, and verify that a fresh launch reaches Connected! and Listening on port 3000 without saving a file to trigger nodemon.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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-app-1 | [nodemon] starting `node src/index.js`
app-app-1 | Waiting for mysql:3306............
app-app-1 | Timeout
app-app-1 | Error: connect ECONNREFUSED 172.20.0.3:3306
app-app-1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) {
app-app-1 | errno: -111,
app-app-1 | code: 'ECONNREFUSED',
app-app-1 | syscall: 'connect',
app-app-1 | address: '172.20.0.3',
app-app-1 | port: 3306,
app-app-1 | fatal: true
app-app-1 | }
app-app-1 | [nodemon] app crashed - waiting for file changes before starting...
Further down in the logs, I saw this line:
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 https://github.com/docker/getting-started/pull/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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 3.1k
- Forks
- 6.4k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de docker/getting-started
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
docker/getting-started#481 · 2 comentarios · 5 reacciones ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 65/100
docker/getting-started#394 · 1 comentario · 3 reacciones ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
docker/getting-started#494 ·
-
Chat Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
docker/getting-started#482 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 1/100
docker/getting-started#477 ·
Todos los issues de docker/getting-started
Issues similares
-
Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Automattic/safe-publish#594 ·
-
内部文件键(绝对路径的 base64)泄漏到界面标签 Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NousResearch/hermes-agent#121143 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100