时间:2021-05-19
一 docker容器状态转换图
二 实战
[root@localhost ~]# docker infoContainers: 0Running: 0Paused: 0Stopped: 0Images: 3Server Version: 17.09.0-ceStorage Driver: overlayBacking Filesystem: xfsSupports d_type: falseLogging Driver: json-fileCgroup Driver: cgroupfsPlugins:Volume: localNetwork: bridge host macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0runc version: 3f2f8b84a77f73d38244dd690525642a72156c64init version: 949e6faSecurity Options:seccomp Profile: defaultKernel Version: 3.10.0-327.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 1Total Memory: 993MiBName: localhost.localdomainID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTBDocker Root Dir: /var/lib/dockerDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Experimental: falseInsecure Registries:127.0.0.0/8Live Restore Enabled: falseWARNING: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will not be supported in future releases.WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabled[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEclearlinux latest 32685d114002 6 days ago 62.5MBbusybox latest 6ad733544a63 6 days ago 1.13MBalpine latest 053cde6e8953 6 days ago 3.96MB[root@localhost ~]# docker run -d --name box1 busybox4ca3d293206cd34e449075491679b0cddd619b451cac7a3d20d5b5daaa6095d8[root@localhost ~]# docker run -itd --name box2 busybox9c1578a50f0b97d48c7501dda6d6e1c3d8b3d9ed0e37416120f91f5a634fb12f[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES9c1578a50f0b busybox "sh" 13 seconds ago Up 11 seconds box24ca3d293206c busybox "sh" 47 seconds ago Exited (0) 45 seconds ago box1[root@localhost ~]# docker run -itd --name box3 busyboxe84a746ea040603aa4db791da77aee2e2502ff5b184e89049a74805671a58ba9[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 5 seconds ago Up 4 seconds box39c1578a50f0b busybox "sh" About a minute ago Up About a minute box24ca3d293206c busybox "sh" 2 minutes ago Exited (0) 2 minutes ago box1[root@localhost ~]# docker infoContainers: 3Running: 2Paused: 0Stopped: 1Images: 3Server Version: 17.09.0-ceStorage Driver: overlayBacking Filesystem: xfsSupports d_type: falseLogging Driver: json-fileCgroup Driver: cgroupfsPlugins:Volume: localNetwork: bridge host macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0runc version: 3f2f8b84a77f73d38244dd690525642a72156c64init version: 949e6faSecurity Options:seccomp Profile: defaultKernel Version: 3.10.0-327.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 1Total Memory: 993MiBName: localhost.localdomainID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTBDocker Root Dir: /var/lib/dockerDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Experimental: falseInsecure Registries:127.0.0.0/8Live Restore Enabled: falseWARNING: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will not be supported in future releases.WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabled[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 4 minutes ago Up 4 minutes box39c1578a50f0b busybox "sh" 6 minutes ago Up 6 minutes box24ca3d293206c busybox "sh" 6 minutes ago Exited (0) 6 minutes ago box1[root@localhost ~]# docker restart 9c9c[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 5 minutes ago Up 5 minutes box39c1578a50f0b busybox "sh" 7 minutes ago Up 2 seconds box24ca3d293206c busybox "sh" 8 minutes ago Exited (0) 8 minutes ago box1[root@localhost ~]# docker pause 9c9c[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 8 minutes ago Up 8 minutes box39c1578a50f0b busybox "sh" 10 minutes ago Up 2 minutes (Paused) box24ca3d293206c busybox "sh" 10 minutes ago Exited (0) 10 minutes ago box1[root@localhost ~]# docker infoContainers: 3Running: 1Paused: 1Stopped: 1Images: 3Server Version: 17.09.0-ceStorage Driver: overlayBacking Filesystem: xfsSupports d_type: falseLogging Driver: json-fileCgroup Driver: cgroupfsPlugins:Volume: localNetwork: bridge host macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0runc version: 3f2f8b84a77f73d38244dd690525642a72156c64init version: 949e6faSecurity Options:seccomp Profile: defaultKernel Version: 3.10.0-327.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 1Total Memory: 993MiBName: localhost.localdomainID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTBDocker Root Dir: /var/lib/dockerDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Experimental: falseInsecure Registries:127.0.0.0/8Live Restore Enabled: falseWARNING: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will not be supported in future releases.WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabled[root@localhost ~]# docker unpause 9c9c[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 11 minutes ago Up 11 minutes box39c1578a50f0b busybox "sh" 13 minutes ago Up 6 minutes box24ca3d293206c busybox "sh" 14 minutes ago Exited (0) 14 minutes ago box1[root@localhost ~]# docker infoContainers: 3Running: 2Paused: 0Stopped: 1Images: 3Server Version: 17.09.0-ceStorage Driver: overlayBacking Filesystem: xfsSupports d_type: falseLogging Driver: json-fileCgroup Driver: cgroupfsPlugins:Volume: localNetwork: bridge host macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslogSwarm: inactiveRuntimes: runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0runc version: 3f2f8b84a77f73d38244dd690525642a72156c64init version: 949e6faSecurity Options:seccomp Profile: defaultKernel Version: 3.10.0-327.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 1Total Memory: 993MiBName: localhost.localdomainID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTBDocker Root Dir: /var/lib/dockerDebug Mode (client): falseDebug Mode (server): falseRegistry: https://index.docker.io/v1/Experimental: falseInsecure Registries:127.0.0.0/8Live Restore Enabled: falseWARNING: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior. Reformat the filesystem with ftype=1 to enable d_type support. Running without d_type support will not be supported in future releases.WARNING: bridge-nf-call-iptables is disabledWARNING: bridge-nf-call-ip6tables is disabled[root@localhost ~]# docker kill 9c9c[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 17 minutes ago Up 17 minutes box39c1578a50f0b busybox "sh" 19 minutes ago Exited (137) 3 seconds ago box24ca3d293206c busybox "sh" 20 minutes ago Exited (0) 20 minutes ago box1[root@localhost ~]# docker stop e8^[[Ae8[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 19 minutes ago Exited (137) 1 second ago box39c1578a50f0b busybox "sh" 21 minutes ago Exited (137) 2 minutes ago box24ca3d293206c busybox "sh" 22 minutes ago Exited (0) 22 minutes ago box1[root@localhost ~]# docker start e8e8[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 22 minutes ago Up 5 seconds box39c1578a50f0b busybox "sh" 24 minutes ago Exited (137) 4 minutes ago box24ca3d293206c busybox "sh" 24 minutes ago Exited (0) 24 minutes ago box1[root@localhost ~]# docker start 9c9c[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 25 minutes ago Up 3 minutes box39c1578a50f0b busybox "sh" 27 minutes ago Up 3 seconds box24ca3d293206c busybox "sh" 28 minutes ago Exited (0) 28 minutes ago box1[root@localhost ~]# docker restart 9c9c[root@localhost ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe84a746ea040 busybox "sh" 26 minutes ago Up 4 minutes box39c1578a50f0b busybox "sh" 28 minutes ago Up 7 seconds box24ca3d293206c busybox "sh" 28 minutes ago Exited (0) 28 minutes ago box1补充知识:一张图看懂docker容器的所有状态
部分解释:
创建容器的命令
run 是create和start的结合
create-created-start
例子:
docker create httpd
OCM硬件信息
docker kill id 强制关闭容器
die某个程序别强制退出,或者进程出错
docker pause :暂停容器中所有的进程。
docker unpause :恢复容器中所有的进程。
以上这篇docker容器状态的转换实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
进入docker容器后如果退出容器,容器就会变成Exited的状态,那么如何退出容器让容器不关闭呢?如果要正常退出不关闭容器,请按Ctrl+P+Q进行退出容器,
1、问题描述安装在docker容器里面的storage一直处于退出状态,导致文件无法存储。2、解决方案查看docker中安装的容器dockerps-a尝试启动容
场景公司项目部署在docker中,由于未知原因容器偶尔会停止,需要写一个脚本监控容器运行状态,如果容器停止了,就再启动该容器shell脚本#!/bin/bash
DockerRunc容器生命周期容器的生命周期涉及到内部的程序实现和面向用户的命令行界面,runc内部容器状态转换操作、runc命令的参数定义的操作、docke
  docker可以实现虚拟化的效果,它包括很多的部分,容器就是其中之一,而容器也是docker的一个重要的概念,容器是独立运行的一个或者是