How to stop running node in docker

后端 未结 8 1973
广开言路
广开言路 2021-02-13 18:02

I have just installed dockers and installed node. I am able to run a basic express site. My issue now is I can\'t stop it. Control-C is not doing anything.

Temporarily w

8条回答
  •  隐瞒了意图╮
    2021-02-13 18:32

    I came across this same problem today, and struggled to find an explanation/solution. I discovered (through trial and error) that this only occurs when the CMD in the Dockerfile is set to:

    CMD [ "node", "server.js" ]
    

    However, Ctrl+C works fine when the CMD is changed to:

    CMD [ "npm", "start" ]
    

    The npm start script in my package.json file is set to node server.js, so I have no idea why this change works, but hopefully this helps.

提交回复
热议问题