I am trying to build two docker images for the two components of by project. One is a node application and the other is the MySQL DB. I am using a script to create the databases and fill up the tables in the DB docker image because I couldn't create stored procedures using the ORM. My configuration for it is like this:
FROM mysql:8.0.26
ADD initialization.sql /docker-entrypoint-initdb.d
ENV MYSQL_ALLOW_EMPTY_PASSWORD=thisisfine
EXPOSE 3306
When I run docker-compose up --build, the database image shuts down which causes issues with my other image. I am unable to figure out why. This is what is present in the logs:
Creating libraryly_db_1 ... done
Creating libraryly_backend_1 ... done
Attaching to libraryly_db_1, libraryly_backend_1
backend_1 | Waiting for the DB to start...
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
db_1 | 2021-08-15 17:10:58+00:00 [Note] [Entrypoint]: Initializing database files
db_1 | 2021-08-15T17:10:58.655968Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.26) initializing of server in progress as process 42
db_1 | 2021-08-15T17:10:58.676504Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1 | 2021-08-15T17:10:59.618507Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db_1 | 2021-08-15T17:11:01.811035Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:01.811791Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:02.140665Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off
the --initialize-insecure option.
db_1 | 2021-08-15 17:11:07+00:00 [Note] [Entrypoint]: Database files initialized
db_1 | 2021-08-15 17:11:07+00:00 [Note] [Entrypoint]: Starting temporary server
db_1 | 2021-08-15T17:11:07.714680Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 91
db_1 | 2021-08-15T17:11:07.750557Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
db_1 | 2021-08-15T17:11:08.000431Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db_1 | 2021-08-15T17:11:08.397505Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:08.397776Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
db_1 | 2021-08-15T17:11:08.399964Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1 | 2021-08-15T17:11:08.400702Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now suppor
ted for this channel.
db_1 | 2021-08-15T17:11:08.407431Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is
accessible to all OS users. Consider choosing a different directory.
db_1 | 2021-08-15T17:11:08.463387Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
db_1 | 2021-08-15T17:11:08.463648Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.26' socket: '/var/run/mysq
ld/mysqld.sock' port: 0 MySQL Community Server - GPL.
db_1 | 2021-08-15 17:11:08+00:00 [Note] [Entrypoint]: Temporary server started.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
db_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
backend_1 | Operation timed out
backend_1 | Starting the server...
db_1 |
db_1 | 2021-08-15 17:11:15+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/initialization.sql
backend_1 |
backend_1 | > libraryly@1.0.0 start /app
backend_1 | > node app
backend_1 |
db_1 |
db_1 |
db_1 | 2021-08-15 17:11:16+00:00 [Note] [Entrypoint]: Stopping temporary server
db_1 | 2021-08-15T17:11:16.132929Z 11 [System] [MY-013172] [Server] Received SHUTDOWN from user root. Shutting down mysqld (Version: 8.0.26).
backend_1 | Listening at: http://localhost:5000
backend_1 | ConnectionRefusedError [SequelizeConnectionRefusedError]: connect ECONNREFUSED 172.23.0.2:3306
backend_1 | at ConnectionManager.connect (/app/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:116:17)
backend_1 | at processTicksAndRejections (internal/process/task_queues.js:93:5)
backend_1 | at async ConnectionManager._connect (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:318:24)
backend_1 | at async /app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:250:32
backend_1 | at async ConnectionManager.getConnection (/app/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:280:7)
backend_1 | at async /app/node_modules/sequelize/lib/sequelize.js:613:26
backend_1 | at async Sequelize.authenticate (/app/node_modules/sequelize/lib/sequelize.js:867:5) {
backend_1 | parent: Error: connect ECONNREFUSED 172.23.0.2:3306
backend_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
backend_1 | errno: -111,
backend_1 | code: 'ECONNREFUSED',
backend_1 | syscall: 'connect',
backend_1 | address: '172.23.0.2',
backend_1 | port: 3306,
backend_1 | fatal: true
I can't figure out what is causing the root user to send a shutdown request. Please help.
in this case You don't need a dockerfile if you're using docker-compose, you can configure your docker-compose file like this
version: "3.7"
services:
mysql:
image: mysql:8.0.17
container_name: localmysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: initialDatabaseName
ports:
- 3306:3306
volumes:
- /your_local/path:/var/lib/mysql
if you want to initialize your db I recommend you to use an ORM what allow you to use database migrations, or run your script from your backend
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.