Reputation: 347
I'm trying to attach to a detached container but it seems to freeze and I have to ctrl-c to get back to the shell.
I start my container with this
sudo docker run -d -t mysql /bin/bash
and when I try to attach it with
sudo docker attach <id>
it does nothing but hold onto my shell session.
However, if I start my container with interactive
sudo docker run -i -t mysql /bin/bash
and ctrl-p/q to exit and then attach with the command above it works perfectly fine.
Is there something I am doing wrong?
Thanks
Upvotes: 1
Views: 1051
Reputation: 32156
with -d
your container runs detached in the background. If you want to interact with it, connect inside this container with docker exec
, or as you have noticed, run not detached but with -i -t
If I start it in interactive mode and ctrl-p/q, does that put it into detach mode?
No, check the doc docs.docker.com/articles/basics/#running-an-interactive-shell, extract "o detach the tty without exiting the shell, # use the escape sequence Ctrl-p + Ctrl-q", -t -i means running an interactive container, with a TTY and capture STDIN
Upvotes: 3