【发布时间】:2018-04-25 05:09:21
【问题描述】:
我将 nodejs 和 knex 用于一些 REST api。 我使用此代码运行 迁移 和 seeds
knex.migrate.latest()
.then(() => {
return knex.seed.run();
})
.then(() => {
// migrations are finished, init server
});
我正在使用 remote 数据库 进行此测试。当我使用 node index.js 从 localhost 运行它时,一切运行良好,迁移运行,然后数据库中填充了种子。但是,当我创建 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