0

I was surprised when command sudo docker ps -a thrown list of containers:

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

I was surprised twice when found that some of them alive. Since festive_bhabha is up I would like attach to it:

sudo docker attach festive_bhabha

But command prints nothing and not returns. Why I can't attach to container?

vico
  • 17,051
  • 45
  • 159
  • 315
  • I think this will help you: [How to get into a docker container?](https://stackoverflow.com/questions/30172605/how-to-get-into-a-docker-container) – tgogos Mar 16 '18 at 10:13

1 Answers1

0

Docker containers are not automatically removed when they exist. You can clean dangling images, exited containers... using:

docker system prune 

The Docker container festive_bhabha seems to be an ubuntu image that might not be generating and output, which explains why no output is shown when running the attach command.

You can check what processes are running inside this container by running:

docker container top festive_bhabha

Alternatively, you can exec inside the container.

docker exec -it festive_bhabha bash
yamenk
  • 46,736
  • 10
  • 93
  • 87
  • Where name `festive_bhabha` came from? Is it automatic generated one by system during container start? – vico Mar 16 '18 at 14:14
  • If you don't give the container a name using `--name` param for docker run, docker generates a random name for the container. – yamenk Mar 16 '18 at 14:15
  • can I somehow get to container with comand `docker attach festive_bhabha` instead of `docker exec -it festive_bhabha bash` ? – vico Mar 16 '18 at 14:23