Hi!!!.. I have got a trouble executing a docker-compose. I will tell that I don’t have much experience in this environment, It is very difficult for me to solve the incidents that arise when I practice on my own.
Well, I have a docker-compose whick it runs two images: one executes node, and the other executes mySql:
version: “3.7”
services:
app:
image: dockeresteban/getting-started:v2
ports:
- 3000:3000
environment:
MYSQL_HOST: mysql
MYSQL_USER: root
MYSQL_PASSWORD: secret
MYSQL_DB: todos
mysql:
image: mysql:5.7
volumes:
- ./todo-mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: todos
The question is that when I execute “docker-compose up -d”, the containers begin to run in the machine, if I write in the bash: docker ps" I see:
esteban@esteban-VirtualBox:~/proyectos/peladonerd/docker/12/multi-container$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
811dfda4ae22 mysql:5.7 “docker-entrypoint.s…” 19 seconds ago Up 17 seconds 3306/tcp, 33060/tcp multi-container_mysql_1
2ac3940b6b3d dockeresteban/getting-started:v2 “docker-entrypoint.s…” 19 seconds ago Up 18 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp multi-container_app_1
But If I look at the logs of my node’s container (getting-started:v2), the system response:
Waiting for mysql:3306…
Timeout
Error: Handshake inactivity timeout
at Handshake. (/app/node_modules/mysql/lib/protocol/Protocol.js:160:17)
at Handshake.emit (events.js:314:20)
at Handshake._onTimeout (/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:124:8)
at Timer._onTimeout (/app/node_modules/mysql/lib/protocol/Timer.js:32:23)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
--------------------
at Protocol._enqueue (/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at PoolConnection.connect (/app/node_modules/mysql/lib/Connection.js:119:18)
at Pool.getConnection (/app/node_modules/mysql/lib/Pool.js:48:16)
at Pool.query (/app/node_modules/mysql/lib/Pool.js:202:8)
at /app/src/persistence/mysql.js:35:14
at new Promise ()
at Object.init (/app/src/persistence/mysql.js:34:12)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
code: ‘PROTOCOL_SEQUENCE_TIMEOUT’,
fatal: true,
timeout: 10000
}
And finally the container downs for itself.
The dockerfile is:
FROM node:12.22.1-alpine3.11
WORKDIR /app
COPY . .
RUN yarn install --production
CMD [“node”, “/app/src/index.js”]
For the response I suppose that the problem comes from the Protocol of the mysql database, but I don’t know how I can change the response time and put more seconds time, I’m looking fot the system file, but I don’t find It. I don’t know if this fix will solve this problem either.
Thanks to everywhere!.