Error in node when PM2 starts multiple processes in docker

2021-09-13T15:41:15: PM2 log: App [kafka:1] starting in -cluster mode- 2021-09-13T15:41:15: PM2 log: App name:kafka id:2 disconnected 2021-09-13T15:41:15: PM2 log: App [kafka:2] exited with code [0] via signal [SIGINT] 2021-09-13T15:41:15: PM2 log: App [kafka:2] starting in -cluster mode- 2021-09-13T15:41:15: PM2 log: App [kafka:1] online 2021-09-13T15:41:15: PM2 log: App [kafka:2] online /bin/bash:1 ELF ^ SyntaxError: Invalid or unexpected token

Docker start use CMD["pm2-runtime","process.json"].

The configuration file looks like this

{
    "apps" : [
        {
            "name": "kafka",
            "script": "node main.js --NODE_ENV=test",
            "log_date_format"  : "YYYY-MM-DD HH:mm:ss",
            "log_file"   : "/home/logs/log.log",
            "error_file" : "/home/logs/err.log",
            "out_file"   : "/home/logs/out.log",
            "instances": 3,
            "exec_mode": "cluster"
        }
    ]
  }

Start three Kafka instances in docker. But it keeps reporting errors. The reason is “exec_mode” in the configuration file. Delete it. In docker, remember to use process blocking to run in the foreground mode. Do not use the background, otherwise it will start frequently and cause error.

Read More: