gpt4 book ai didi

docker - docker在启动时撰写run bash命令

转载 作者:行者123 更新时间:2023-12-02 20:14:22 25 4
gpt4 key购买 nike

我有一个docker-compose文件,其中结合了nginx和一个node js应用程序。整个过程开始时,我需要运行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

这是我的 docker 撰写:
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

一个明确的例子将不胜感激,谢谢。

最佳答案

嘿,您可以使用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"

关于docker - docker在启动时撰写run bash命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44537553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com