How can I connect to a docker container running offline?
If I start the docker container in a separate mode using the command:
docker run -d ubuntu
the container leaves immediately. docker ps -a
gives output (selected columns shown):
CONTAINER ID IMAGE COMMAND STATUS
245fe871a1e3 ubuntu "/bin/bash" Exited (0) 4 minutes ago
Is it possible to run the same container (container id 245fe871a1e3
) interactively with a terminal session?
source to share
I am afraid there is no such way of archiving this. docker attach
and docker exec
only work with a running container, but if you are a docker start
container in your case, it will exit immediately again, because CMD
- /bin/bash
.
There's also a discussion about this, write some key info here:
Unable to enter a stopped container because the processes disappeared and hence the namespaces also disappeared.
source to share