Lets say I have a container running and I do
docker exec -ti container-id /bin/bash
Then I detach from this container and want to attach again
If I do this
docker attach container-id
I wont go back to that bash that I created. Instead I will go to the main process.
How can I attach to that bash again ?
Advertisement
Answer
You can’t. While the docker exec
documentation suggests it supports the same “detach” key sequence as docker run
, the exec’d process doesn’t have any Docker-level identity (beyond its host and container pids) and there’s no way to re-attach to that shell.
(In the Docker API, “exec instance” is an actual object so this isn’t technically impossible; the CLI just has no support for it.)
The workflow you’re describing sounds more like what you’d run with screen
or tmux
in a virtual machine.