title: Use here document with ENTRYPOINT/CMD in Dockerfile
body: <h1>What I want to do</h1>
  
  <p>My goal is to end up with a Docker image which - as soon as a container is launched from it - reads input from stdin until it meets EOF. Then, it simply writes back what has been read to stdout.</p>
  
  <p>Basically, my idea was this should be possible by using the here document syntax <code>cat &lt;&lt; EOF</code>.</p>
  
  <p><br/></p>
  
  <h1>What I did so far</h1>
  
  <p>So far, I tried different variants with the CMD Dockerfile instruction but had no success until now. From all the images I've created I launched containers with <code>docker run -it myimage</code> to keep the container's stdin attached.</p>
  
  <h3>Variant 1</h3>
  
  <pre><code> FROM alpine 3.7
   CMD ["cat", "&lt;&lt;", "EOF"]
  </code></pre>
  
  <p>This leads to the following error:</p>
  
  <pre><code>cat: can't open '&lt;&lt;': No such file or directory
  cat: can't open 'EOF': No such file or directory
  </code></pre>
  
  <p><br/></p>
  
  <h3>Variant 2</h3>
  
  <pre><code> FROM alpine 3.7
   CMD ["cat &lt;&lt; EOF"]
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code> container_linux.go:265: starting container process caused "exec: \"cat &lt;&lt; EOF\": executable file not found in $PATH"
  </code></pre>
  
  <p><br/></p>
  
  <h3>Variant 3</h3>
  
  <pre><code> FROM alpine:3.7
   CMD ["sh", "-c", "cat &lt;&lt; EOF"]
  </code></pre>
  
  <p>Result: </p>
  
  <p>This does nothing but returns immediately. </p>
  
  <p><br/></p>
  
  <h3>Variant 4</h3>
  
  <pre><code> FROM alpine: 3.7
   CMD "cat &lt;&lt; EOF"
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code> /bin/sh: cat &lt;&lt; EOF: not found
  </code></pre>
  
  <p><br/></p>
  
  <h1>What I expect</h1>
  
  <p>I'm searching for a solution that behaves like described above. The following <code>docker run</code> command works perfectly, but I'd like to define this as the default entry point for my Docker image:</p>
  
  <pre><code> $ docker run -it alpine cat &lt;&lt; EOF
   &gt; Hello Docker
   &gt; EOF
   Hello Docker
  </code></pre>