'How to check open shells on a container?

How could I check if I have currently running interactive shells on a container, like for instance opened with:

docker exec -it mycontainer sh

Is there a way to retrieve this information ?



Solution 1:[1]

You can use docker ps to get container ID.
Exec into container with

docker exec -it mycontainer sh

or

docker exec -it mycontainer bash

Then, in the shell of the container, run the command hostname, check output with container ID.

enter image description here

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 quoc9x