title: running netcat inside docker container
body: <p>I have created docker images using the below Dockerfile.</p>
  <pre><code> FROM ubuntu
   RUN apt-get update \
    &amp;&amp; DEBIAN_FRONTEND=noninteractive apt-get install -y \
      net-tools \
    &amp;&amp; apt-get clean \
    &amp;&amp; rm -rf /var/lib/apt/lists/*
  RUN apt-get update \
    &amp;&amp; DEBIAN_FRONTEND=noninteractive apt-get install -y \
      netcat \
    &amp;&amp; apt-get clean \
    &amp;&amp; rm -rf /var/lib/apt/lists/*
  EXPOSE 1234
  ENTRYPOINT bin/bash
  CMD [&quot;nc&quot;, &quot;-l&quot;, &quot;1234&quot;]
  </code></pre>
  <p>I created image from the above docker file and run the docker container using the image by running below command.</p>
  <pre><code>docker run -d  -i -p 1234:1234 --name daemon  nc-ubuntu nc -l 1234
  </code></pre>
  <p>In another terminal, I run the below command.</p>
  <pre><code>telnet localhost 1234
  </code></pre>
  <p>I got the below output.</p>
  <pre><code>$ telnet localhost 1234
  Trying ::1...
  Connected to localhost.
  Escape character is '^]'.
  Connection closed by foreign host.
  </code></pre>
  <p>I am trying this as this is sample from book docker in practice in chapter 2 by manning for running docker as daemon process.</p>
  <p>As per author I should get below result.</p>
  <pre><code>$ telnet localhost 1234
  Trying ::1...
  Connected to localhost.
  Escape character is '^]'.
  hello daemon
  </code></pre>
  <p>Any idea why I'm not getting expected output.</p>