title: Using custom shell script as docker entrypoint
body: <p>I’m trying to use docker-compose to bring up a container. As an <strong>ENTRYPOINT</strong>, that container has a simple bash script that I wrote. Now, when I try to bring up the container in any of the below ways:   </p>
  
  <ul>
  <li><code>docker-compose up</code>  </li>
  <li><code>docker-compose up foo</code> </li>
  </ul>
  
  <p>it doesn’t complete. i.e., trying to attach (<code>docker exec -i -t $1 /bin/bash</code>) to the running container, fails with:</p>
  
  <blockquote>
    <p>Error response from daemon: Container xyz is restarting, wait until the container is running.</p>
  </blockquote>
  
  <p>I tried playing around with putting commands in the background. That didn’t work. </p>
  
  <p><strong>my-script.sh</strong></p>
  
  <pre><code>cmd1 &amp;
  cmd2 &amp;&amp;
  ...
  cmdn &amp;
  </code></pre>
  
  <p>I also tried <em>i)</em> with and without <code>entrypoint: /bin/sh /usr/local/bin/my-script.sh</code> and <em>ii)</em> with and without the <code>tty: true</code> option. No dice.</p>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '2'
  services:
    foo:
      build:
        context: .
        dockerfile: Dockerfile.foo
      ...
      tty: true
      entrypoint: /bin/sh /usr/local/bin/my-script.sh
  </code></pre>
  
  <p>Also tried just a manual docker build / run cycle. And (without launching <code>/bin/sh</code> in the <strong>ENTRYPOINT</strong> ) the run just exits. </p>
  
  <pre><code>$ docker build ... .
  $ docker run -it ... 
  ... shell echos commands here, then exits
  $
  </code></pre>
  
  <p>I'm sure its something simple. What's the solution here? </p>