Reputation: 11069
I try to follow this tutorial, but when I execute my app nothing happens
My Dockerfile (CHANGED)
FROM keymetrics/pm2-docker-alpine:7
WORKDIR /api
RUN npm install pm2 -g
ADD . .
CMD ["pm2-docker", "ecosystem.config.js"]
And my 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,
},
},
],
};
After run the docker ..
docker run -d -p 3000:3000 --name api api:latest
Nothing happens.. follow the result of 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
If I run without -d
option ..
> 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]$
Upvotes: 3
Views: 1826
Reputation: 5991
Remove the RUN npm install pm2 -g
, because PM2 is already bundled into pm2-docker-alpine
Upvotes: 1