Dockerfiler如何使用多个启动命令entrypoint


两个办法,一个是CMD不用中括号框起来,将命令用"&&"符号链接:

# 用nohup框起来,不然npm start执行了之后不会执行后面的 CMD nohup sh -c 'npm start && node ./server/server.js'

另一个方法是不用CMD,用ENTRYPOINT命令,指定一个执行的shell脚本,然后在entrypoint.sh文件中写上要执行的命令:

ENTRYPOINT ["./entrypoint.sh"]

entrypoint.sh文件如下:

// entrypoint.sh nohup npm start & nohup node ./server/server.js &




实际示例:

EXPOSE 8002
EXPOSE 9999

ENTRYPOINT cnpm i  && npm run ci  &&  pm2 start google-chrome   --interpreter none   --   --headless   --disable-gpu   --disable-translate   --disable-extensions   --disable-background-networking   --safebrowsing-disable-auto-update   --disable-sync   --metrics-recording-only   --disable-default-apps   --no-first-run   --mute-audio   --hide-scrollbars   --no-sandbox  --remote-debugging-port=9999   && tail -f /root/logs/master-stdout.log 

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM