title: docker run with --interactive and --tty flag
body: <p>Edit:</p>
  
  <p>Someone mark duplicate of <a href="https://stackoverflow.com/questions/48368411/what-is-docker-run-it-flag">this question</a>, but it does not explain the underlying mechanism at all.</p>
  
  <p>But on contrast, <a href="https://stackoverflow.com/questions/30137135/confused-about-docker-t-option-to-allocate-a-pseudo-tty">this stack overflow</a> solve my confusion in Case I, <strong>but not Case II</strong>.</p>
  
  <hr>
  
  <p>I am newbie in docker and i am confused about the usage of --interactive, --attach flag and those concepts involved</p>
  
  <p>I will show my confusion using <a href="https://hub.docker.com/_/busybox" rel="nofollow noreferrer">busybox</a> in docker hub.</p>
  
  <hr>
  
  <p><strong>Case I</strong> : </p>
  
  <p>When I run a container using the below commands. <code>docker run --interactive --tty busybox sh</code></p>
  
  <p>A container is running and accepting input
  <a href="https://i.stack.imgur.com/I8Tz8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I8Tz8.png" alt="enter image description here"></a></p>
  
  <p>According to the <a href="https://docs.docker.com/engine/reference/commandline/run/" rel="nofollow noreferrer">document</a>, --interactive flag used to </p>
  
  <blockquote>
    <p>Keep STDIN open even if not attached</p>
  </blockquote>
  
  <p>I don't understand what is the meaning of <strong>even if not attached to</strong>, attached to what?</p>
  
  <hr>
  
  <p><strong>Case II</strong> : 
  Then I exit the container and try to start it using
  <code>docker start --attach abdd796820b1</code> . </p>
  
  <p>The terminal seems accepting input as well, but when I type ls or echo, it does not give response.
    <a href="https://i.stack.imgur.com/6zS3a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6zS3a.png" alt="enter image description here"></a>
  What did the --attach flag do?</p>
  
  <h2>Please help.</h2>