附在容器上

时间:2018-03-16 10:02:38

标签: docker

当命令sudo docker ps -a抛出容器列表时,我感到很惊讶:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                         PORTS               NAMES
efd4879e92e0        ubuntu              "/bin/bash"         About an hour ago   Exited (0) 20 minutes ago                          elated_newton
7db432be894c        ubuntu              "/bin/bash"         About an hour ago   Exited (0) 18 minutes ago                          nervous_meninsky
aef01293fdc9        ubuntu              "/bin/bash"         About an hour ago   Up About an hour                                   priceless_ramanujan
87cfd461b465        ubuntu              "/bin/bash"         About an hour ago   Up About an hour                                   festive_bhabha
1dcb6f9618d8        ubuntu              "/bin/bash"         About an hour ago   Up About an hour                                   mystifying_poitras
0f1636eb9cc1        hello-world         "/hello"            About an hour ago   Exited (0) About an hour ago                       sharp_murdock
2a3a1fb03ada        hello-world         "/hello"            About an hour ago   Exited (0) About an hour ago                       admiring_brattain
77c8e7ef5770        hello-world         "/hello"            16 hours ago        Exited (0) 16 hours ago                            unruffled_shannon
808805085c59        centos              "6.9"               17 hours ago        Created                                            youthful_aryabhata
a1438a7811c2        centos              "/bin/bash"         17 hours ago        Exited (0) 17 hours ago                            sleepy_neumann
fce6a95f8f5a        ubuntu              "/bin/bash"         17 hours ago        Exited (0) 17 hours ago                            cranky_ritchie
e17b5f98bbc5        ubuntu              "/bin/bash"         17 hours ago        Exited (0) 17 hours ago                            unruffled_ritchie
cafbbe52dad5        hello-world         "/hello"            17 hours ago        Exited (0) 17 hours ago                            hungry_pike
d40ac9c16e9c        ubuntu              "/bin/bash"         17 hours ago        Exited (0) 17 hours ago                            brave_babbage
5efd22250d0e        ubuntu              "/bin/bash"         17 hours ago        Exited (0) 17 hours ago                            confident_lalande
471e22652bc3        ubuntu              "/bin/bash"         17 hours ago        Exited (0) 17 hours ago                            vigorous_wing
b68f43ebae50        ubuntu              "bash"              17 hours ago        Exited (127) 17 hours ago                          confident_euler
a83eae486f76        ubuntu              "bash"              17 hours ago        Exited (0) 17 hours ago                            infallible_murdock
88b3b4e73e5e        hello-world         "/hello"            17 hours ago        Exited (0) 17 hours ago                            thirsty_bhabha
deb88e38d347        hello-world         "/hello"            17 hours ago        Exited (0) 17 hours ago                            nervous_ptolemy

当他们发现其中一些人活着时,我感到很惊讶。由于festive_bhabha已经上线,我想加入它:

sudo docker attach festive_bhabha

但命令不打印任何内容而不返回。为什么我无法连接到容器?

1 个答案:

答案 0 :(得分:0)

Docker容器存在时不会自动删除。您可以使用以下方法清理悬空图像,退出容器......

docker system prune 

Docker容器festive_bhabha似乎是一个可能无法生成和输出的ubuntu映像,这解释了为什么在运行attach命令时没有显示输出。

您可以通过运行以下命令来检查此容器中正在运行的进程:

docker container top festive_bhabha

或者,您可以在容器内执行。

docker exec -it festive_bhabha bash