如何在Docker中停止运行节点 [英] How to stop running node in docker

查看:222
本文介绍了如何在Docker中停止运行节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了泊坞窗并安装了节点。
我能够运行基本的快递网站。我现在的问题是我无法阻止它。 Control-C没有做任何事情。

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.

暂时我要退出的是:


  1. 关闭码头工人的码头。

  2. 打开一个新容器。

  3. 搜索所有正在运行的Docker容器。

  4. 然后 docker stop [容器]

  1. Close the docker's terminal.
  2. Open a new one.
  3. Search for all docker containers that is running.
  4. Then docker stop [container]

这是正确的方法吗?

推荐答案

我今天也遇到了同样的问题,并且努力寻找解释/解决方案。我发现(通过反复试验)只有在Dockerfile中的CMD设置为以下情况时才会发生这种情况:

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" ]

但是,将CMD更改为Ctrl + C可以正常工作:

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

CMD [ "npm", "start" ]

package.json 文件中的 npm start 脚本设置为 node server.js ,所以我不知道为什么此更改有效,但是希望这会有所帮助。

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.

这篇关于如何在Docker中停止运行节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆