运行docker composer时mysql给出错误-Node js [英] mysql give error when running the docker composer - node js

查看:205
本文介绍了运行docker composer时mysql给出错误-Node js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用docker部署我的node js应用程序,但是当我运行docker时,它组成了一个错误. MySQL中有一个问题.我在终端中运行命令:

I am trying to deploy my node js application with docker but when I am running the docker compose it giving an error at the end. There is an issue in MySQL.I am running the command in terminal:

docker-compose up --build

docker-compose up --build

docker-compose.yml

version: '3'
services:
  db:
    build:
      context: .
      dockerfile: ./docker/Dockerfile-mysql
    container_name: mydb
    command: --explicit_defaults_for_timestamp=1
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=yes
      - MYSQL_DATABASE=dbautokab
      - MYSQL_USER=root
      - MYSQL_PASSWORD=
    networks:
      - helicopter-network
    healthcheck:
      test: "exit 0"

  helicopter-api:
    build:
      context: .
      dockerfile: ./docker/Dockerfile-api
    depends_on:
      - db
    networks: ['helicopter-network']
    environment:
        - PORT=3000
        - DATABASE_HOST=db
        - DATABASE_PASSWORD=
        - EGG_SERVER_ENV=local
        - NODE_ENV=development
    ports:
      - "3000:3000"

networks:
  helicopter-network:
    driver: bridge

Dockerfile-api

FROM node:10-slim

USER node

RUN mkdir -p /home/node/app

WORKDIR /home/node/app

COPY --chown=node package*.json ./

RUN npm install

COPY --chown=node . .

COPY wait-for-it.sh /

ENV HOST=0.0.0.0 PORT=3000

EXPOSE ${PORT}

CMD /wait-for-it.sh db:3306 -- npm start

Dockerfile-mysql

FROM mysql:5.7.26

COPY ./docker/init_db.sql /docker-entrypoint-initdb.d/

init_db.sql

CREATE DATABASE IF NOT EXISTS dbautokab;
GRANT ALL PRIVILEGES on dbautokab.*
TO 'root'@'%'
WITH GRANT OPTION;

错误(终端输出):

Attaching to mydb, autokab_helicopter-api_1
mydb              | 2019-06-19T09:20:34.704713Z 0 [Note] mysqld     (mysqld 5.7.26) starting as process 1 ...
mydb              | 2019-06-19T09:20:34.708930Z 0 [Note] InnoDB: PUNCH HOLE support available
mydb              | 2019-06-19T09:20:34.708962Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mydb              | 2019-06-19T09:20:34.708977Z 0 [Note] InnoDB: Uses event mutexes
mydb              | 2019-06-19T09:20:34.708991Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mydb              | 2019-06-19T09:20:34.709016Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
mydb              | 2019-06-19T09:20:34.709043Z 0 [Note] InnoDB: Using Linux native AIO
mydb              | 2019-06-19T09:20:34.709674Z 0 [Note] InnoDB: Number of pools: 1
mydb              | 2019-06-19T09:20:34.709895Z 0 [Note] InnoDB: Using CPU crc32 instructions
mydb              | 2019-06-19T09:20:34.711940Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mydb              | 2019-06-19T09:20:34.729374Z 0 [Note] InnoDB: Completed initialization of buffer pool
mydb              | 2019-06-19T09:20:34.732229Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mydb              | 2019-06-19T09:20:34.747795Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4800!
mydb              | 2019-06-19 09:20:34 0x7f811365e740  InnoDB: Assertion failure in thread 140192352954176 in file ut0ut.cc line 942
mydb              | InnoDB: We intentionally generate a memory trap.
mydb              | InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
mydb              | InnoDB: If you get repeated assertion failures or crashes, even
mydb              | InnoDB: immediately after the mysqld startup, there may be
mydb              | InnoDB: corruption in the InnoDB tablespace. Please refer to
mydb              | InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
mydb              | InnoDB: about forcing recovery.
mydb              | 09:20:34 UTC - mysqld got signal 6 ;
mydb              | This could be because you hit a bug. It is also possible that this binary
mydb              | or one of the libraries it was linked against is corrupt, improperly built,
mydb              | or misconfigured. This error can also be caused by malfunctioning hardware.
mydb              | Attempting to collect some information that could help diagnose the problem.
mydb              | As this is a crash and something is definitely wrong, the information
mydb              | collection process might fail.

推荐答案

运行docker-compose之后,请检查:

After run the docker-compose please check:

docker ps

docker ps

您会发现您的mysql容器正常运行,并进行测试以连接到容器内部以检查是否已创建数据库

You will find your mysql container run correctly and test to connect inside of your container to check if the database are created

docker exec -it container_name/bin/bash

docker exec -it container_name /bin/bash

mysql -u根

显示数据库;

节点尝试附加数据库时发生问题.

The problem occured when node try to attach db.

Attaching to mydb, autokab_helicopter-api_1

我建议:

  • 删除您构建的mysql和node图像
  • 仅重建mysql并测试其是否正常运行
  • 别忘了在mysql容器上使用volume:'/var/lib/mysql'不会丢失数据.
  • 如果mysql现在可以正常工作,则可以启动节点容器

希望对您有帮助

这篇关于运行docker composer时mysql给出错误-Node js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆