深度阅读

How to stop a Docker container?

作者
作者
2023年08月22日
更新时间
8.36 分钟
阅读时间
0
阅读量

To stop a Docker container, you can use the docker stop command followed by the container ID or name:

docker stop <container_id_or_name>

This command sends a SIGTERM signal to the container’s main process, allowing it to gracefully shut down before the container is actually stopped. If the container does not stop within a certain grace period (usually 10 seconds), docker stop will then send a SIGKILL signal to forcibly stop the container.

Alternatively, you can use the docker kill command to immediately stop the container by sending it a SIGKILL signal without any grace period:

docker kill <container_id_or_name>

Please keep in mind that stopping or killing a container may cause data loss if the container was not properly configured to persist data using data-only containers or volumes.

相关标签

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。