我有一个docker-compose文件,我在其中组合了nginx和一个节点js app。我需要在整个事情开始时运行shell命令sudo sysctl -w net.core.somaxconn=65536
,但我找不到如何做到的明确示例。
这是我的节点应用程序dockerfile:
FROM node:6.9.0
ADD . /myapi
WORKDIR /myapi
RUN npm install
EXPOSE 1337
ENTRYPOINT ["node"]
CMD ["./index.js"]
这是我的nginx dockerfile:
FROM nginx
MAINTAINER me
COPY nginx.conf /etc/nginx/nginx.conf
COPY ssl-certificates/ServerCertificate.cer /var/www/ssl/ServerCertificate.cer
COPY ssl-certificates/SSLPrivateKey.key /var/www/ssl/SSLPrivateKey.key
这是我的码头作品:
version: "3"
services:
api:
image: myregistry/my-api:1.033
build: ./api
ports:
- "1337"
environment:
NODE_ENV: qa
deploy:
replicas: 12
networks:
- api-network
proxy:
image: myregistry/my-api-proxy:1.033
build:
context: ./nginx
args:
RUNNING_MODE: prod
ulimits:
nproc: 65535
nofile:
soft: 10240
hard: 20480
ports:
- "80:80"
- "443:443"
links:
- api
deploy:
replicas: 3
networks:
- api-network
networks:
api-network:
driver: overlay
非常感谢一个明显的例子,谢谢。
答案 0 :(得分:0)
嘿,您可以使用ENTRYPOINT
,如下所示:
FROM node:6.9.0
ADD . /myapi
WORKDIR /myapi
RUN npm install
EXPOSE 1337
ENTRYPOINT "/bin/node index.js" && "sudo sysctl -w net.core.somaxconn=65536"