title: Cannot pipe docker pid to bash command
body: <p>I commonly want to open a bash shell on a docker image. A multi-command process for this would be:</p>
  
  <pre><code>$ docker ps
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
  bba983d72d48        scubbo/datenight    "apachectl -DFOREGROU"   7 days ago          Up 7 days           0.0.0.0:80-&gt;80/tcp   pensive_bell
  $ docker exec -it bba983d72d48 bash
  </code></pre>
  
  <p>I'd like to shortcut this. However, I get the following error:</p>
  
  <pre><code>$ docker ps | awk 'NR &gt; 1 {print $1}' | xargs -I {} docker exec -it {} bash
  cannot enable tty mode on non tty input
  </code></pre>
  
  <p>From a little Googling, I found <a href="https://stackoverflow.com/questions/29380344/docker-exec-it-returns-cannot-enable-tty-mode-on-non-tty-input">this issue</a> - however, if I drop the <code>-t</code> option, the command "completes" immediately.</p>
  
  <p>I have confirmed that manually copy-pasting the output of <code>$ docker ps | awk 'NR &gt; 1 {print $1}'</code> into the appropriate position of <code>docker exec -it {} bash</code> is successful.</p>
  
  <p>EDIT: Cutting out the <code>docker ps</code> from the pipe, the following also fails:</p>
  
  <pre><code>$ docker ps
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
  4f20409c37b7        scubbo/datenight    "apachectl -DFOREGROU"   8 days ago          Up 8 days           0.0.0.0:80-&gt;80/tcp   drunk_northcutt
  $ docker ps -q
  4f20409c37b7
  $ echo '4f20409c37b7' | xargs -I {} docker exec -it {} bash
  cannot enable tty mode on non tty input
  </code></pre>