Multicontainer Docker应用程序在部署时失败

时间:2018-05-28 13:18:58

标签: node.js mongodb docker elastic-beanstalk

所以我在亚马逊上将我的应用程序部署到弹性beanstalk时遇到了问题。我的应用程序是一个多容器Docker应用程序,其中包含节点服务器和mongoDB。不知何故应用程序每次都崩溃,我从mongoDB得到这个奇怪的错误。 错误如下:

18-05-28T12:53:02.510+0000 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 3867 processes, 32864 files. Number of processes should be at least 16432 : 0.5 times number of files.
2018-05-28T12:53:02.540+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-05-28T12:53:02.541+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
2018-05-28T12:53:03.045+0000 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2018-05-28T12:53:03.045+0000 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2018-05-28T12:53:03.045+0000 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2018-05-28T12:53:03.045+0000 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2018-05-28T12:53:03.047+0000 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2018-05-28T12:53:03.161+0000 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2018-05-28T12:53:03.161+0000 I CONTROL  [signalProcessingThread] now exiting
2018-05-28T12:53:03.161+0000 I CONTROL  [signalProcessingThread] shutting down with code:0

这是我的Dockerrun.aws.json文件:

{
  "AWSEBDockerrunVersion": 2,
  "volumes":[
    {
      "name": "mongo-app",
      "host": {
        "sourcePath": "/var/app/mongo-app"
      }
    },
    {
      "name": "some-api",
      "host": {
        "sourcePath": "/var/app/some-api"
      }
    }
  ],
  "containerDefinitions": [
      {
        "name": "mongo-app",
        "image": "mongo:latest",
        "memory": 128,
        "portMappings": [
          {
            "hostPort": 27017,
            "containerPort": 27017
          }
        ],
        "mountPoints": [
          {
            "sourceVolume": "mongo-app",
            "containerPath": "/data/db"
          }
        ]
      },
      {
        "name": "server",
        "image": "node:8.11",
        "memory": 128,
        "portMappings": [
          {
            "hostPort": 80,
            "containerPort": 8001
          }
        ],
        "links": [
          "mongo-app"
        ],
        "mountPoints":[
          {
            "sourceVolume": "some-api",
            "containerPath": "/some-data"
          }
        ]
      }
  ]
}

这是我的Dockerfile:

FROM node:8.11
RUN mkdir -p /api
WORKDIR /api
COPY package.json /api
RUN cd /api && npm install
COPY . /api
EXPOSE 8001
CMD ["node", "api/app.js"]

任何想法为什么应用程序崩溃而不部署?在我看来,mongoDB导致了问题,但我无法理解或找到问题的根源。

提前谢谢!

1 个答案:

答案 0 :(得分:0)

我花了一段时间试图解决这个问题。

解决方案:为"containerPath": "/data/configdb"添加一个安装点。 Mongo希望能够同时写入/data/db/data/configdb

此外,您可能希望将"memory": 128的Mongo提升到更高的水平。