docker容器状态的转换实现

 更新时间:2020年11月19日 09:09:19   作者:chengqiuming  
这篇文章主要介绍了docker容器状态的转换实现,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

一 docker容器状态转换图

二 实战

[root@localhost ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 3
Server Version: 17.09.0-ce
Storage Driver: overlay
Backing Filesystem: xfs
Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
 Profile: default
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 993MiB
Name: localhost.localdomain
ID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: 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 disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@localhost ~]# docker images
REPOSITORY     TAG         IMAGE ID      CREATED       SIZE
clearlinux     latest       32685d114002    6 days ago     62.5MB
busybox       latest       6ad733544a63    6 days ago     1.13MB
alpine       latest       053cde6e8953    6 days ago     3.96MB
[root@localhost ~]# docker run -d --name box1 busybox
4ca3d293206cd34e449075491679b0cddd619b451cac7a3d20d5b5daaa6095d8
[root@localhost ~]# docker run -itd --name box2 busybox
9c1578a50f0b97d48c7501dda6d6e1c3d8b3d9ed0e37416120f91f5a634fb12f
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
9c1578a50f0b    busybox       "sh"        13 seconds ago   Up 11 seconds                  box2
4ca3d293206c    busybox       "sh"        47 seconds ago   Exited (0) 45 seconds ago            box1
[root@localhost ~]# docker run -itd --name box3 busybox
e84a746ea040603aa4db791da77aee2e2502ff5b184e89049a74805671a58ba9
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        5 seconds ago    Up 4 seconds                  box3
9c1578a50f0b    busybox       "sh"        About a minute ago  Up About a minute               box2
4ca3d293206c    busybox       "sh"        2 minutes ago    Exited (0) 2 minutes ago    
        box1
[root@localhost ~]# docker info
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 3
Server Version: 17.09.0-ce
Storage Driver: overlay
Backing Filesystem: xfs
Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
 Profile: default
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 993MiB
Name: localhost.localdomain
ID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: 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 disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        4 minutes ago    Up 4 minutes                  box3
9c1578a50f0b    busybox       "sh"        6 minutes ago    Up 6 minutes                  box2
4ca3d293206c    busybox       "sh"        6 minutes ago    Exited (0) 6 minutes ago            box1
[root@localhost ~]# docker restart 9c
9c
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        5 minutes ago    Up 5 minutes                  box3
9c1578a50f0b    busybox       "sh"        7 minutes ago    Up 2 seconds                  box2
4ca3d293206c    busybox       "sh"        8 minutes ago    Exited (0) 8 minutes ago            box1
[root@localhost ~]# docker pause 9c
9c
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        8 minutes ago    Up 8 minutes                  box3
9c1578a50f0b    busybox       "sh"        10 minutes ago   Up 2 minutes (Paused)              box2
4ca3d293206c    busybox       "sh"        10 minutes ago   Exited (0) 10 minutes ago            box1
[root@localhost ~]# docker info
Containers: 3
Running: 1
Paused: 1
Stopped: 1
Images: 3
Server Version: 17.09.0-ce
Storage Driver: overlay
Backing Filesystem: xfs
Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
 Profile: default
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 993MiB
Name: localhost.localdomain
ID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: 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 disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@localhost ~]# docker unpause 9c
9c
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        11 minutes ago   Up 11 minutes                  box3
9c1578a50f0b    busybox       "sh"        13 minutes ago   Up 6 minutes                  box2
4ca3d293206c    busybox       "sh"        14 minutes ago   Exited (0) 14 minutes ago            box1
[root@localhost ~]# docker info
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 3
Server Version: 17.09.0-ce
Storage Driver: overlay
Backing Filesystem: xfs
Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
seccomp
 Profile: default
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 993MiB
Name: localhost.localdomain
ID: 6ULL:CFMN:YT7C:4RXZ:2CJ4:26H2:D4Y6:YHUP:SH7L:QLEQ:AWEB:EWTB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: 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 disabled
WARNING: bridge-nf-call-ip6tables is disabled
[root@localhost ~]# docker kill 9c
9c
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS            PORTS        NAMES
e84a746ea040    busybox       "sh"        17 minutes ago   Up 17 minutes                  box3
9c1578a50f0b    busybox       "sh"        19 minutes ago   Exited (137) 3 seconds ago            box2
4ca3d293206c    busybox       "sh"        20 minutes ago   Exited (0) 20 minutes ago            box1
[root@localhost ~]# docker stop e8
^[[Ae8
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS            PORTS        NAMES
e84a746ea040    busybox       "sh"        19 minutes ago   Exited (137) 1 second ago            box3
9c1578a50f0b    busybox       "sh"        21 minutes ago   Exited (137) 2 minutes ago            box2
4ca3d293206c    busybox       "sh"        22 minutes ago   Exited (0) 22 minutes ago            box1
[root@localhost ~]# docker start e8
e8
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS            PORTS        NAMES
e84a746ea040    busybox       "sh"        22 minutes ago   Up 5 seconds                   box3
9c1578a50f0b    busybox       "sh"        24 minutes ago   Exited (137) 4 minutes ago            box2
4ca3d293206c    busybox       "sh"        24 minutes ago   Exited (0) 24 minutes ago            box1
[root@localhost ~]# docker start 9c
9c
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        25 minutes ago   Up 3 minutes                  box3
9c1578a50f0b    busybox       "sh"        27 minutes ago   Up 3 seconds                  box2
4ca3d293206c    busybox       "sh"        28 minutes ago   Exited (0) 28 minutes ago            box1
[root@localhost ~]# docker restart 9c
9c
[root@localhost ~]# docker ps -a
CONTAINER ID    IMAGE        COMMAND       CREATED       STATUS           PORTS        NAMES
e84a746ea040    busybox       "sh"        26 minutes ago   Up 4 minutes                  box3
9c1578a50f0b    busybox       "sh"        28 minutes ago   Up 7 seconds                  box2
4ca3d293206c    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容器状态的转换实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • docker安装nginx并部署前端项目的全过程

    docker安装nginx并部署前端项目的全过程

    作为一个前端,代码写完,最后部署到服务器,这是一个必须要了解的过程,这篇文章主要给大家介绍了关于docker安装nginx并部署前端项目的相关资料,需要的朋友可以参考下
    2022-05-05
  • Docker 学习文档(知识结构整理)

    Docker 学习文档(知识结构整理)

    这篇文章主要介绍了Docker 学习文档的相关资料,需要的朋友可以参考下
    2016-11-11
  • Docker阿里云RocketMQ 4.5.1部署流程详解

    Docker阿里云RocketMQ 4.5.1部署流程详解

    RocketMQ是阿里开源的一款分布式消息中间件,具有日志监控、消息推送、金融报文、电信信令、削峰填谷等功能.接下来通过本文给大家介绍Docker阿里云RocketMQ 4.5.1部署流程,感兴趣的朋友一起看看吧
    2021-05-05
  • docker build运行报错source: not found解决分析

    docker build运行报错source: not found解决分析

    这篇文章主要为大家介绍了docker build运行报错source: not found解决分析,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-09-09
  • 解决docker安装jenkins容器内无法访问外网

    解决docker安装jenkins容器内无法访问外网

    这篇文章为大家主要介绍了docker安装jenkins容器内无法访问外网的问题解决,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-11-11
  • Docker compose 编排工具详解

    Docker compose 编排工具详解

    Compose是一个用于定义和运行多容器Docker应用程序的工具。使用Compose,您可以使用Compose文件来配置应用程序的服务。然后,使用单个命令,您可以从配置中创建并启动所有服务
    2021-09-09
  • Docker容器的调试技巧之docker logs与docker service logs解读

    Docker容器的调试技巧之docker logs与docker service logs

    这篇文章主要介绍了Docker容器的调试技巧之docker logs与docker service logs,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2024-01-01
  • docker根据已生成的容器生成docker-compose.yml文件的实现步骤

    docker根据已生成的容器生成docker-compose.yml文件的实现步骤

    这篇文章主要给大家介绍了docker 如何根据已生成的容器生成docker-compose.yml 文件,文中有详细的代码示例和实现步骤,对大家的学习有一定的帮助,需要的朋友可以参考下
    2023-10-10
  • Docker如何多步构建生成dubbo-admin镜像详解

    Docker如何多步构建生成dubbo-admin镜像详解

    dubbo-admin是dubbo框架的管理平台,下面这篇文章主要给大家介绍了关于Docker如何多步构建生成dubbo-admin镜像的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
    2018-04-04
  • docker容器使用GPU方法实现

    docker容器使用GPU方法实现

    本文主要介绍了docker容器使用GPU方法实现,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-05-05

最新评论