停止正在运行的docker容器及docker容器删除

1停止正在运行中的docker进程

执行以下命令

docker ps

结果如下

ONTAINER ID        IMAGE                                                                       COMMAND             CREATED             STATUS              PORTS               NAMES
ffc1792471da        registry.cn-shanghai.aliyuncs.com/tcc-public/super-mario-ppo:r1             "/bin/bash"         5 seconds ago       Up 4 seconds                            modest_wright

执行以下命令停止进程

docker kill ffc1792471da

查看结果

docker ps

结果如下

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

2docker容器的删除

首先停止希望删除的容器(参考上述停止方法)

执行以下命令查看所有容器

docker ps -a

结果如下

CONTAINER ID   IMAGE                                                                       COMMAND       CREATED        STATUS                    PORTS     NAMES
1a18447e378b   registry.cn-shanghai.aliyuncs.com/tcc-public/super-mario-ppo:localdisplay   "/bin/bash"   23 hours ago   Created                             vibrant_keller
2c150c5e7fe9   registry.cn-shanghai.aliyuncs.com/tcc-public/super-mario-ppo:localdisplay   "/bin/bash"   24 hours ago   Created                             sleepy_feynman
c9338fa03f8c   hello-world                                                                 "/hello"      24 hours ago   Exited (0) 24 hours ago             sharp_solomon

执行以下命令删除,1a18447e378b为上述命令查询出来的CONTAINER ID

docker rm 1a18447e378b

查看结果

docker ps -a

结果如下

CONTAINER ID   IMAGE                                                                       COMMAND       CREATED        STATUS                    PORTS     NAMES
2c150c5e7fe9   registry.cn-shanghai.aliyuncs.com/tcc-public/super-mario-ppo:localdisplay   "/bin/bash"   24 hours ago   Created                             sleepy_feynman
c9338fa03f8c   hello-world                                                                 "/hello"      24 hours ago   Exited (0) 24 hours ago             sharp_solomon

删除成功

你可能感兴趣的:(docker,容器,运维)