Sometimes I want to see what is going on inside a running Docker container.
docker ps we can see the running containers.
Using either the
CONTAINER ID or
NAMES we can enter the container:
docker exec --interactive --tty <container id/name> bash
In a workflow where containers are stopped, removed and a new container started it is cumbersome to update the above command with a new container id.
Instead, we can get the last started container with the command
docker ps -laq and use this with
docker exec --interactive --tty $(docker ps -laq) bash