Expressjs app started with PM2 in Docker dies with SIGINT

I have a VERY SIMPLE Expressjs app – basically a library wrapper with the single post call.

Here is the app.js conents:

  • Cannot publish any docker containers
  • Getting error ImportMismatchError while running py.test
  • How can I numactl membind a process inside Docker container?
  • How to avoid recreation of a linked container with docker-compose?
  • Can't connect to ElasticSearch Docker cluster which run on local virtual machine using Java API
  • Using compose in (fabric8io) docker-maven-plugin deactivates image build
  • var compression = require('compression');
    var express = require('express');
    var path = require('path');
    var bodyParser = require('body-parser');
    
    var convert = require('./routes/convert');
    
    var app = express();
    
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(compression());
    
    app.use('/', convert);
    
    module.exports = app;
    

    Then I created Dockerfile to containerize the app:

    FROM mhart/alpine-node
    WORKDIR /src
    
    COPY package.json ./
    COPY app.js ./
    ADD routes/ ./routes/
    ADD bin/ ./bin/
    
    RUN npm i
    RUN npm install -g pm2@2.4.0
    
    EXPOSE 3000
    CMD ["pm2-docker", "app.js"]
    

    And here is what happens when I try to bring it up (this is with the DEBUG=express:*)

    [STREAMING] Now streaming realtime logs for [all] processes
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:route new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:route post /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "x-powered-by" to true
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "etag" to 'weak'
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "etag fn" to [Function: wetag]
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "env" to 'development'
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "query parser" to 'extended'
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "query parser fn" to [Function: parseExtendedQueryString]
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "subdomain offset" to 2
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "trust proxy" to false
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "trust proxy fn" to [Function: trustNone]
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application booting in development mode
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "view" to [Function: View]
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "views" to '/src/views'
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:application set "jsonp callback name" to 'callback'
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router use / query
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router use / expressInit
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router use / jsonParser
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router use / urlencodedParser
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router use / compression
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router use / router
    2017-05-14-04:15:09 0|app      | Sun, 14 May 2017 04:15:09 GMT express:router:layer new /
    2017-05-14-04:15:09 PM2        | App [app] with id [0] and pid [89], exited with code [0] via signal [SIGINT]
    2017-05-14-04:15:09 PM2        | Starting execution sequence in -fork mode- for app name:app id:0
    2017-05-14-04:15:09 PM2        | App name:app id:0 online
    

    looks like that process dies and being restarted then all the time. I’m not a Node developer just need this one get working and looking forward to any suggestions and help.

    Thanks.

  • What does --net=host option in Docker command really do?
  • docker-php-ext-install - why always using dev?
  • docker nginx and php, php cant connect to localhost
  • How to use HTTPS / SSL with self signed certificate on Mgt Development Environment
  • Running PostgreSql inside Docker
  • How-to run a node.js docker instance dropping into a shell that is auto-tailing logs
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.