'docker attach doesn't attach to the container

I ran a docker container on one of the terminals, on the other terminal:

$ docker container ls
CONTAINER ID   IMAGE                                         COMMAND                  CREATED         STATUS         PORTS     NAMES
80b6be3a7d56   rbonghi/isaac-ros-tutorial:realsense-camera   "/ros_entrypoint.sh …"   9 seconds ago   Up 8 seconds             inspiring_almeida

and then I run

$ docker attach inspiring_almeida

now nothing seems to happen, cursor moves to a new line.

$ docker attach inspiring_almeida

What am I doing wrong? I expected to see something like root@80b6be3a7d56

P.s. I'm accessing the machine that I run docker via SSH - if that matters.



Solution 1:[1]

Run docker exec -it inspiring_almeida /bin/bash. It runs a shell inside the container.

attach just connects your input/output terminal with the container's input/output.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 loki