For some reason, I can't detach from Docker containers after running docker attach <container>
. The documentation says to use Ctrl-p, Ctrl-q
, but that doesn't seem to work. I've also tried ctrl-q + ctrl-p
(combination, as opposed to in-sequence) and ctrl-shift-q, ctrl-shift-p
and ctrl-shift-q + ctrl-shift-p
. Even setting a detach key, for example --detach-keys="p"
won't detach from the container.
Furthermore, other things don't seem to be working. For example, according to documentation, ctrl-c
should cause the attached container to stop and detach. However, I haven't been able to get ctrl-c
working on any of my containers. Unlike ctrl-q
, however, ctrl-c
renders feedback as expected, showing a ^C
in the terminal.
I've noticed that for some reason, when I press ctrl-p
, I get a ^P
in the terminal, but pressing ctrl-q
or ctrl-shift-q
renders no terminal feedback.
Can anyone venture a guess as to why this might be happening?
I'm using iTerm2 on MacOS if it matters. Also, the containers in question were launched with docker-compose
.
Edit: For clarity, I launched my container with docker-compose up
on the following compose
file:
version: '3'
services:
test:
build:
context: .
dockerfile: Dockerfile
container_name: container-test
ports:
- "5050:5050"
Then I attach using:
$ docker attach container-test
Edit 2: After some testing, I can confirm this issue still exists in MacOS Terminal.
You can use --sig-proxy=false
to prevent signals being passed to container and detach using Ctrl+C
:
docker attach --sig-proxy=false container-test
This seems to be a known issue: https://github.com/docker/for-mac/issues/1598
I found that by adding the following lines to my docker-compose
, I could get it to exit and respond to inputs.
services:
test:
// etc...
stdin_open: true
tty: true
// etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With