title: How to write a Dockerfile which I can start a service and run a shell and also accept arguments for the shell?
body: <p>In a Dockerfile, the latest instruction is:</p>
  
  <pre><code>CMD  sudo chown -R user:user /home/user/che &amp;&amp; \
       sudo service docker start &amp;&amp; \
       cd /home/user/che/bin/ &amp;&amp; ./che.sh run
  </code></pre>
  
  <p>It works but I can't pass more arguments to <code>./che.sh</code>.</p>
  
  <p>The <code>che.sh</code> checks if the internal <code>docker</code> is started after doing other tasks. And it can accept several optional arguments, like <code>-r:111.111.111.111</code>. </p>
  
  <p>I tried to modify the instruction as:</p>
  
  <pre><code>RUN sudo chown -R user:user /home/user/che &amp;&amp; \
       sudo service docker start
  ENTRYPOINT ["/home/user/che/bin/che.sh"]
  </code></pre>
  
  <p>in order to invoke it like <code>docker run -it --priviledged my/che -r:111.111.111.111 run</code>, but the <code>che.sh</code> shell will report internal <code>docker</code> is not working well.</p>
  
  <p>I also tried:</p>
  
  <pre><code>ENTRYPOINT ["sudo service docker start", "&amp;&amp;", "/home/user/che/bin/che.sh run"]
  </code></pre>
  
  <p>even:</p>
  
  <pre><code>ENTRYPOINT ["sh", "-c" "sudo service docker start &amp;&amp; /home/user/che/bin/che.sh run"]
  </code></pre>
  
  <p>But it will report <code>sudo service docker start</code> is not found in $PATH, or the <code>che.sh</code> doesn't run.</p>
  
  <p>What's the correct way to write it?</p>
  
  <ol>
  <li><code>sudo service docker start</code> should run when <code>che.sh</code> is invoked</li>
  <li>I need to pass arguments from outside to <code>che.sh</code>, like <code>docker run -it --priviledged my/che -r:111.111.111.111 run</code></li>
  </ol>