我的node.js kubernetes开发服务器陷入了崩溃循环。日志显示:
/bin/busybox:1
ELF
^
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:992:16)
at Module._compile (internal/modules/cjs/loader.js:1040:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:776:16)
at Function.executeUserEntryPoint [as runMain (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
stream closed
我找到了正在运行的映像,kubectl describe
并在外壳中运行了该映像。它应该运行此命令(来自Dockerfile
):
...
ENTRYPOINT ["node", "--max-old-space-size=4096", "--enable-source-maps"]
CMD ['node_modules/.bin/rollup','-cw']
因此,在shell中,我运行了:
❯ dsh myregistry/project/server:R4SUGQt
+dsh:1> docker run --rm -it --entrypoint sh myregistry/project/server:R4SUGQt -c '{ command -v zsh && exec zsh -il ;} || { command -v bash && bash -il ;} || { command -v ash && ash -il ;}'
/bin/ash
06884c20d5cc:/app# node --max-old-space-size=4096 --enable-source-maps node_modules/.bin/rollup -cw
而且效果很好。那么,这个错误源于何处?堆栈中的所有路径都跟踪内部(internal/modules/...
),而不是我的脚本或汇总。
我使用的node:alpine
是当前在Node v14.11.0上的基础映像。
直接运行
docker run --rm myregistry/project/server:R4SUGQ
确实重现错误。
跑步
docker run -it myregistry/project/server:R4SUGQt node_modules/.bin/rollup -cw
工作正常...我的CMD
语法有问题吗?
CMD ['node_modules/.bin/rollup','-cw']
这是我在中使用的单引号CMD
。
在以下事实之后找到此reddit帖子:https : //www.reddit.com/r/docker/comments/9wn5gw/be_aware_of_the_quotes_in_your_dockerfile/
真是浪费时间。。。如果有人遇到类似错误,将这个问题留在这里,也许对他们来说是可以谷歌的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句