title: docker attach: Why can't I detach from my Docker container?
body: <p>For some reason, I can't detach from Docker containers after running <code>docker attach &lt;container&gt;</code>. The documentation says to use <code>Ctrl-p, Ctrl-q</code>, but that doesn't seem to work. I've also tried <code>ctrl-q + ctrl-p</code> (combination, as opposed to in-sequence) and <code>ctrl-shift-q, ctrl-shift-p</code> and <code>ctrl-shift-q + ctrl-shift-p</code>. Even setting a detach key, for example <code>--detach-keys="p"</code> won't detach from the container. </p>
  
  <p>Furthermore, other things don't seem to be working. For example, according to documentation, <code>ctrl-c</code> should cause the attached container to stop and detach. However, I haven't been able to get <code>ctrl-c</code> working on any of my containers. Unlike <code>ctrl-q</code>, however, <code>ctrl-c</code> renders feedback as expected, showing a <code>^C</code> in the terminal.</p>
  
  <p>I've noticed that for some reason, when I press <code>ctrl-p</code>, I get a <code>^P</code> in the terminal, but pressing <code>ctrl-q</code> or <code>ctrl-shift-q</code> renders no terminal feedback.</p>
  
  <p>Can anyone venture a guess as to why this might be happening?</p>
  
  <p>I'm using iTerm2 on MacOS if it matters. Also, the containers in question were launched with <code>docker-compose</code>.</p>
  
  <p>Edit: For clarity, I launched my container with <code>docker-compose up</code> on the following <code>compose</code> file:</p>
  
  <pre><code>version: '3'
  
  services:
    test:
      build:
        context: .
        dockerfile: Dockerfile
      container_name: container-test
      ports:
        - "5050:5050"
  </code></pre>
  
  <p>Then I attach using:</p>
  
  <pre><code>$ docker attach container-test
  </code></pre>
  
  <p>Edit 2: After some testing, I can confirm this issue still exists in MacOS Terminal. </p>