简体   繁体   English

杀死dotnet进程时杀死docker容器

[英]killing docker container when killing dotnet process

I am running a docker container with dotnet base image, I want to kill the whole container after 10 min.我正在运行一个带有 dotnet 基本映像的 docker 容器,我想在 10 分钟后杀死整个容器。 I thought if i kill the dotnet process with:我想如果我用以下方法杀死 dotnet 进程:

Process.GetCurrentProcess().Kill();

it should kill the container as it was the process that started container but it's not working.它应该杀死容器,因为它是启动容器的进程,但它不工作。 Can someone please tell me what's the best way of killing container after some spesific time?有人可以告诉我在特定时间后杀死容器的最佳方法是什么?

Assuming it's traditional Linux docker (I'm unfamiliar with docker on Windows Server), then you should be able to stop the container by killing the process with pid 1. Assuming it's traditional Linux docker (I'm unfamiliar with docker on Windows Server), then you should be able to stop the container by killing the process with pid 1.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM