docker容器杀不死

In the previous article ‘learn how to create and start Docker containers’, we discussed the docker run, create and start commands. We discussed how to customize the properties of a container. We will build on the concepts covered in that tutorial in this tutorial. This tutorial assumes you have a good understanding of the main parts of Docker, you have set up Docker and you have some knowledge of images and containers.

在上一篇文章“ 学习如何创建和启动Docker容器 ”中,我们讨论了Docker运行,创建和启动命令。 我们讨论了如何自定义容器的属性。 在本教程中,我们将以该教程中涵盖的概念为基础。 本教程假定您对Docker的主要部分有充分的了解,已经设置了Docker并且对图像和容器有一定的了解。

Starting and stopping containers is different from stopping and resuming ordinary processes. A process stop does not pause the process, it causes the process to exit. A stopped container is not returned by docker ps. To stop a container you use the docker stop command and pass the name of the container and the number of seconds before a container is killed. The default number of seconds the command will wait before the killing is 10 seconds.Before we demonstrate how to kill a container, let us check if there are containers running. The command below will do that.

启动和停止容器不同于停止和恢复普通过程。 进程停止不会暂停进程,而是导致进程退出。 docker ps不返回已停止的容器。 要停止容器,请使用docker stop命令,并传递容器的名称以及杀死容器之前的秒数。 在杀死之前,命令等待的默认秒数为10秒。在演示如何杀死容器之前,让我们检查是否有容器在运行。 下面的命令将执行此操作。

sudo docker ps

The docker ps command returns a list of all running containers, from our output above we do not have any running container. In the ‘learn how to use images’ tutorial, we demonstrated how to search and download images from the Docker hub. We downloaded a WordPress image that we can use to create a container. Let us start a container using the WordPress image with the command below.

docker ps命令返回所有正在运行的容器的列表,从上面的输出中我们没有任何正在运行的容器。 在“学习如何使用映像”教程中,我们演示了如何从Docker集线器中搜索和下载映像。 我们下载了可用于创建容器的WordPress图像。 让我们使用带有以下命令的WordPress图像启动一个容器。

sudo docker create --name firstkill bitnami/wordpress

After starting the container use sudo docker ps -a command to return all containers.

启动容器后,使用sudo docker ps -a命令返回所有容器。

From the output above, we can see the container we have created. Something to note about docker is that all containers that were running at shut down will be restarted on a reboot.

从上面的输出中,我们可以看到我们创建的容器。 关于Docker的注意事项是,所有在关闭状态下运行的容器将在重新启动后重新启动。

We use the run command to run our container by passing the ID returned by docker ps -a to run as shown below.

我们使用run命令通过传递docker ps -a返回的ID来运行容器,如下所示。

sudo docker run fe1f71042611

Use docker ps to return only the containers that are running.

使用docker ps仅返回正在运行的容器。

From the output above our container shows its status as exited. When a container exits with code 0 there are no errors.

从上面的输出中,我们的容器将其状态显示为退出。 当容器以代码0退出时,没有错误。

Because containers are just like any other Unix process we can interact with them via Unix signals. For example, specifying the number of seconds before a container is killed is an example of a signal. A normal process exit receives a SIGTERM signal. When a SIGTERM signal is sent but a process does not exist within the specified time, a SIGKILL signal is sent.

因为容器与任何其他Unix进程一样,我们可以通过Unix信号与它们进行交互。 例如,指定杀死容器之前的秒数是信号的示例。 正常流程出口会收到SIGTERM信号。 发送SIGTERM信号但在指定时间内不存在进程时,将发送SIGKILL信号。

When stopping a container is not possible you have to kill it. To kill a container you use docker kill command and pass the container ID. You can pass any Unix signal when calling the kill command. When you kill a container you can start it again just like you start a container that was properly stopped.

如果无法停止容器,则必须将其杀死。 要杀死容器,请使用docker kill命令并传递容器ID。 调用kill命令时,可以传递任何Unix信号。 当您杀死容器时,可以像重新启动已正确停止的容器一样重新启动它。

When you do not need a container momentarily to perform administrative functions, it is convenient to pause other than stop containers. Pausing containers rely on cgroups freezer which blocks the scheduling of frozen containers.

当您暂时不需要容器来执行管理功能时,除了停止容器之外,还可以方便地暂停。 暂停容器依赖于cgroups冻结器,该冻结器阻止冻结容器的调度。

A key difference between pausing and stopping containers is in the persistence of state. When a container is stopped any resources allocated to it such as memory are released while a paused container does not release its allocated resources.

暂停和停止容器之间的主要区别在于状态的持久性。 当容器停止时,分配给它的所有资源(例如内存)都会释放,而暂停的容器不会释放其分配的资源。

The commands below start our firstkill container, pause it and check its status. Use the container ID returned by sudo docker ps -a.

下面的命令启动我们的firstkill容器,暂停它并检查其状态。 使用sudo docker ps -a返回的容器ID。

sudo docker run fe1f71042611sudo docker pause fe1f71042611sudo docker ps -a

The actions of creating and manipulating containers result in many image layers and container-specific folders. Cleaning up these resources is important. In the next section, we look at how you can remove images and containers.

创建和操作容器的操作会产生许多图像层和特定于容器的文件夹。 清理这些资源很重要。 在下一节中,我们将介绍如何删除图像和容器。

To remove a container pass the container ID to the docker rm command.

要删除容器,请将容器ID传递给docker rm命令。

The docker images command returns a list of all images on your host. To delete an image pass the ID returned by docker images to docker rmi command. An example of deleting an image is shown below.

docker images命令返回主机上所有图像的列表。 要删除映像,请将docker images返回的ID传递给docker rmi命令。 删除图像的示例如下所示。

sudo docker imagessudo docker rmi

Our attempt to remove the helloworld image above failed because there is a running container based on the image. We should always remove a container before we can remove an image. The error gives you the ID of the container making it very simple to remove the container. Let us remove the container, then remove the image.

我们尝试删除上面的helloworld映像的尝试失败,因为存在基于该映像的正在运行的容器。 在删除图像之前,应始终删除容器。 该错误为您提供了容器的ID,从而使删除容器变得非常简单。 让我们删除容器,然后删除图像。

In this tutorial, we discussed the difference between normal processes and docker containers. We discussed how to stop a running container. We also discussed how to kill a running container. We noted the difference between stopping and killing a container. We discussed how to pause and resume a container. Finally, we discussed how to remove images and containers.

在本教程中,我们讨论了正常进程和Docker容器之间的区别。 我们讨论了如何停止正在运行的容器。 我们还讨论了如何杀死正在运行的容器。 我们注意到停止和杀死容器之间的区别。 我们讨论了如何暂停和恢复容器。 最后,我们讨论了如何删除图像和容器。

WE HAVE ALSO CREATED AN EXCLUSIVE ARTICLE ON “BEST C & C++ IDES & EDITORS” FOR PROGRAMMERS TO ENHANCE THE EFFICIENCY & PRODUCTIVITY. THIS ARTICLE ALSO INCLUDES SOME COOL INFOGRAPHICS ON C & C++ PROGRAMMING! DO READ IT!

我们还为程序员提供了有关“ 最佳C&C ++ IDE和编辑器 ”的专论,以提高效率和生产率。 该文章还包括有关C和C ++编程的一些凉爽信息! 阅读它!

Originally published at https://blog.eduonix.com on February 13, 2020

最初于 2020 2月13日发布在 https://blog.eduonix.com

翻译自: https://medium.com/eduonix/learn-how-to-stop-kill-and-clean-up-docker-containers-2fd311c0c384

docker容器杀不死


http://www.taodudu.cc/news/show-4816081.html

相关文章:

  • Android_常驻进程(杀不死的进程)
  • app之 杀不死的进程
  • nginx服务,杀不死nginx进程
  • android开启服务应用禁止被杀死,Android Service服务如何不被杀死
  • Linux杀不死木马,杀不死进程,自启动进程
  • 杀不死的Service
  • 禁止穿透 uniapp
  • 【react】antd DatePicker禁止当天前后时间
  • Antd RangePicker 时间日期选择器 禁用当前时间往后的日期及现在时间往后的时分秒禁选
  • antd disabledDate 选择禁用特定的时间范围
  • 如何让ElementUI中的时间控件禁止选中过去时间
  • Windows10系统禁止运行脚本问题
  • Ant Design of Vue 中 日期时间控件 禁止选中的(日期——)设置
  • ElementUI日期时间选择器限制时间范围,禁止此刻之前的所有时间选择(精确到,时、分、秒)、pickerOptions、日期选择器范围选择
  • vue2 + elementui 日期时间选择器 禁止选择当前时间之前的日期及时间,并添加相应校验规则
  • 华为USG防火墙-建立安全策略禁止上班时间访问其他网站
  • elementui DateTimePicker组件 限制时间范围(包含时分秒)
  • iview+时间选择器+禁止选择事件
  • ElementUI DateTimePicker设置当前日期之前的时间禁止选择
  • 时间组件关于禁选时间的设置(禁选当前之前的时间、禁止选择某个范围之外的时间等)
  • 移动端选择时间时禁止软键盘弹出
  • vue使用 element-ui 禁止 DateTimePicker 选择时间
  • 注册表禁止修改系统时间
  • React中antd日期选择框,指定区间禁用时间
  • 禁止浏览器滑动
  • element 时间选择器禁止选择以前或以后的时间
  • linux 用户禁止登陆,禁止Linux用户登录方法
  • element-ui日期时间选择框picker-options如何禁用时间范围
  • el-date-picker 禁止时间xaun ze
  • LabVIEW公式节点

docker容器杀不死_了解如何停止,杀死和清理Docker容器相关推荐

  1. mysql 进程一直杀不死_进程一直杀不死

    就是一个简单的杀死进程,名字也是对的,不知道为何用下面方法一直杀不死 private void KillProcess(string processName) { //获得进程对象,以用来操作 Sys ...

  2. docker启动nginx后挂了_学员整理笔记系列8 启动docker后运行不了vmware该怎么办?...

    看过poptest关于Dcoker视频的同学应该都会涉及到vmware,有没有碰到过启动docker后运行不了vmware情况,这里表扬一下郭同学,不光学的好,还能总结问题-希望再接再厉. 我们在运行 ...

  3. centos7 杀不死 httpd (Apache )

    今天遇到一个问题,杀不死httpd (Apache ),杀死后,它又重开了一个进程,继续搞事情,一直占着我的80端口. 解决办法: 直接使用命令: pkill httpd ok ,这就杀死了. 前因后 ...

  4. 如何快速清理docker资源

    前言 如果经常使用 docker,你会发现 docker 占用的资源膨胀很快,其中最明显也最容易被察觉的应该是对磁盘空间的占用.本文将介绍如何快速的清理 docker 占用的系统资源,具体点说就是删除 ...

  5. desktop docker 无法卸载_关于Docker:Docker – 无法移除死容器

    我无法删除死容器,它在重新启动Docker服务后再次出现. docker ps -a CONTAINER ID         STATUS 11667ef16239         Dead 然后 ...

  6. Docker container 杀不掉 docker 死掉怎么办?

    Docker container 杀不掉 docker 死掉怎么办? Sorry!忘记更新了, 当时好像是重启了机器, 然后进去强制删掉的.

  7. docker配置容器mysql启动参数_修改Docker容器启动配置参数

    有时候,我们创建容器时忘了添加参数 --restart=always ,当 Docker 重启时,容器未能自动启动, 现在要添加该参数怎么办呢,方法有二: 1.Docker 命令修改 docker c ...

  8. docker 容器运行 golang程序_「Docker」 - 运行 amp; 管理容器

    容器是基于容器技术所建立和运行的轻量级应用运行环境,它是Docker封装和管理应用程序或微服务的「集装箱」,在Docker中,容器是最核心的部分. 一.容器的创建和启动 Docker容器的生命周期里分 ...

  9. docker修改容器映射的端口_解密 Docker 挂载文件,宿主机修改后容器里文件没有修改...

    问题 使用 Docker Volumes 时,有时需要挂载一个宿主机目录或者文件,提供数据可持续或者容器内部服务配置文件. 使用命令 docker run -it --rm -v /root/test ...

最新文章

  1. 深入浅出ThreadLocal,你会吗?
  2. WhatsApp用户数突破10亿 每天发送消息420亿条
  3. SCLS:中科院遗传发育在拟南芥二半萜类化合物调控根系微生物组取得突破进展
  4. Spring 报It is indirectly referenced。。
  5. myeclipse tomcat内存溢出解决方法
  6. Linux中添加pycharm源,linux下python+pycharm安装
  7. 大数据互联网架构阶段 Redis(二)
  8. 考试 彩色 离散化+类暴力
  9. 支付宝备用金七天不还会不会上征信?
  10. akshare写etf动量滚动策略
  11. 翻译:使用 AWS Deep Racer 的日志分析工具
  12. maven缺失ojdbc6解决方法(手动安装ojdbc6)
  13. 利用云主机搭建游戏加速器(仅限国内加速)
  14. 计算机串口程序配置,串口设置软件 串口调试工具如何使用
  15. php太平洋时间转成北京时间,北京时间 → 太平洋时间 换算表 和太平洋时间 → 北京时间 换算表...
  16. 键盘忍者:无需鼠标即可启动任何应用程序
  17. 21年年后离职找工作的随笔杂谈
  18. 如何下载 Google Play 应用的apk
  19. 分享 | NB-IoT智能井盖传感器
  20. xampp mysql密码忘记_XAMPP重置MySQL密码

热门文章

  1. Java之智力题【史上最全】
  2. Hive 优化--SQL执行顺序、Hive参数、数据倾斜 、小文件优化
  3. sizeof(string)到底是多少?
  4. 泛微ecology 修改在线预览附件 大小限制
  5. MySql的安装和卸载
  6. Stable Diffusion V2.1非标准分辨率图像高清渲染
  7. Win10 home vs pro vs enterprise vs enterprise LTSC
  8. 在计算机中这样切换大小英语字母,英文大小写转换器在线
  9. 计算机专业术语及其解释,计算机专业术语解释
  10. 为云而生、多快好省,这就是星星海的style!