我尝试关注this tutorial,但当我执行我的应用时,没有任何事情发生
我的Dockerfile(已更改)
FROM keymetrics/pm2-docker-alpine:7
WORKDIR /api
RUN npm install pm2 -g
ADD . .
CMD ["pm2-docker", "ecosystem.config.js"]
我的ecosystem.config.js
..
const maxMemory = process.env.WEB_MEMORY || 80;
const nodeEnv = process.env.NODE_ENV || 'development';
module.exports = {
apps: [
{
name: 'api',
script: 'api/index.js',
node_args: [
'--optimize_for_size', '--max_old_space_size=400', '--gc_interval=100',
],
instances: process.env.WEB_CONCURRENCY || -1,
exec_mode: 'cluster',
max_memory_restart: `${maxMemory}M`,
env: {
PORT: process.env.PORT || 3000,
NODE_ENV: nodeEnv,
},
},
],
};
运行docker ..
docker run -d -p 3000:3000 --name api api:latest
没有任何反应..请遵循docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
167cb2769438 api:latest "pm2-docker start ..." 50 seconds ago Exited (1) 47 seconds ago
如果我没有-d
选项运行..
> docker run -it -p 3000:3000 --name api api:latest
module.js:472
throw err;
^
Error: Cannot find module 'commander'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/CLI/RuntimeCLI.js:4:17)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
[vagrant@localhost]$
答案 0 :(得分:1)
删除RUN npm install pm2 -g
,因为PM2已经捆绑到pm2-docker-alpine