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