以 docker CMD 运行 PM2-runtime npm start 的问题
Issue with runing PM2-runtime npm start as docker CMD
我正在尝试 运行 pm2-runtime npm start
作为 docker CMD。
当我进入容器并且 运行 pm2-runtime npm start
一切正常,但我想自动化它。
我试过:
CMD ["pm2-runtime", "npm start"]
CMD ["pm2-runtime", "npm", "start"]
CMD ["pm2-runtime", "'npm start'"]
以上命令不起作用,都是导致这种错误的原因
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
Seams 是一个简单的问题,pm2-运行time 能够启动 npm,所以我做错了什么?
首先,npm start
和pm2-runtime
都运行应用在前台,然后有什么特殊原因运行宁npm start
用pm2-运行时间?
你可以用 process.yml 代替 npm start
.proper Node.js production environment。
process.yml
apps:
- script : myapp.js
name : 'myapp'
error_file : './logs/myapp.log'
out_file : './logs/myapp.log'
您也可以在 YML 配置文件中启动多个进程。
CMD ["pm2-runtime", "process.yml"]
现在来解决您的问题,您只需将 CMD 更改为以下即可。
CMD pm2-runtime 'npm start'
或
CMD ["/bin/sh", "-c", "pm2-runtime 'npm start'"]
完整的演示应用,您可以查看nodejs-docker-pm2-runtime
我正在尝试 运行 pm2-runtime npm start
作为 docker CMD。
当我进入容器并且 运行 pm2-runtime npm start
一切正常,但我想自动化它。
我试过:
CMD ["pm2-runtime", "npm start"]
CMD ["pm2-runtime", "npm", "start"]
CMD ["pm2-runtime", "'npm start'"]
以上命令不起作用,都是导致这种错误的原因
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
Seams 是一个简单的问题,pm2-运行time 能够启动 npm,所以我做错了什么?
首先,npm start
和pm2-runtime
都运行应用在前台,然后有什么特殊原因运行宁npm start
用pm2-运行时间?
你可以用 process.yml 代替 npm start
.proper Node.js production environment。
process.yml
apps:
- script : myapp.js
name : 'myapp'
error_file : './logs/myapp.log'
out_file : './logs/myapp.log'
您也可以在 YML 配置文件中启动多个进程。
CMD ["pm2-runtime", "process.yml"]
现在来解决您的问题,您只需将 CMD 更改为以下即可。
CMD pm2-runtime 'npm start'
或
CMD ["/bin/sh", "-c", "pm2-runtime 'npm start'"]
完整的演示应用,您可以查看nodejs-docker-pm2-runtime