我的docker容器使用本机C ++插件模块运行节点js应用程序。如果本机模块发生崩溃(分段错误),则容器不会重新启动。我们使用Docker撰写文件,将重启策略设置为“始终”#。 任何人都知道我们应该如何管理这个,以便容器在崩溃后重新启动。
Docker撰写文件
version: '2'
services:
mongo:
image: mongo:3.4
restart: always
ports:
- "27017:27017"
volumes:
- ./mongodb:/data/db
mongo-seed:
image: db_seed_data
links:
- mongo
web:
image: software/img
ports:
- "1600:1600"
- "8000:8000"
depends_on:
- mongo
restart: always
volumes:
- ./certs:/certs
links:
- mongo
nginx:
image: software/custom_nginx
restart: always
depends_on:
- web
ports:
- "443:443"
links:
- web
volumes:
- ./certs:/etc/nginx/certs
Docker文件
FROM nodesource/xenial:6.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
libkrb5-dev ssl-cert nghttp2 libnghttp2-dev
RUN mkdir -p core
RUN mkdir -p core/parse
RUN mkdir -p /core/cloud
RUN mkdir -p /core/public
RUN mkdir -p /core/certs
COPY index.js /core/
COPY package.json /core/
COPY config.json /core/
COPY /core/build/Release/core_addon.node /core/
COPY /cloud/main.js /core/cloud/
COPY /public /core/public/
WORKDIR /core
RUN npm install
EXPOSE 1600
EXPOSE 8000
CMD [ "npm", "start" ]
谢谢