【问题标题】:knex seed not working in a docker environmentknex 种子在 docker 环境中不起作用
【发布时间】:2018-04-25 05:09:21
【问题描述】:

我将 nodejsknex 用于一些 REST api。 我使用此代码运行 迁移seeds

knex.migrate.latest()
.then(() => {
    return knex.seed.run();
})
.then(() => {
    // migrations are finished, init server

});

我正在使用 remote 数据库 进行此测试。当我使用 node index.jslocalhost 运行它时,一切运行良好,迁移运行,然后数据库中填充了种子。但是,当我创建 Docker 映像并运行它时,迁移 会按预期工作,但 seeds 会失败。日志输出如下:

Segmentation fault
npm ERR! code ELIFECYCLE
npm ERR! errno 139
npm ERR! com.app@0.2.0 start: `ENV=prod node index.js`
npm ERR! Exit status 139
npm ERR! 
npm ERR! Failed at the com.app@0.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2017-11-12T12_20_43_664Z-debug.log

问题是当容器立即停止时,我无法访问日志文件。

那么,有什么建议吗?

【问题讨论】:

  • 你能分享你的 Dockerfile 吗?您是否将应用程序文件夹映射到某处?你如何启动 docker 容器?看起来您的 node_modules 文件夹有问题。

标签: node.js postgresql docker


【解决方案1】:

如果问题是您无法查看日志以进行进一步诊断,也许您可​​以查看其中一个loging method

【讨论】:

  • 好来源,10x
【解决方案2】:

问题似乎是 Docker 映像中未正确安装库。该库是 Bcrypt(我在种子文件中使用它来散列一些永久用户的密码)。所以我最终将 bcrypt 更改为 bryptjs,现在 docker 映像构建并正常运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-23
    • 1970-01-01
    • 2015-01-29
    • 1970-01-01
    • 2020-08-14
    • 1970-01-01
    相关资源
    最近更新 更多