title: How to use wait-for-it in docker-compose file?
body: <p>Do I have to first have to clone the wait-for-it repo and edit the parts of the wait-for-it.sh file?</p>
  <p><a href="https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh" rel="noreferrer">https://github.com/vishnubob/wait-for-it/blob/master/wait-for-it.sh</a></p>
  <p>I'm trying to make my main file fire after 5 seconds after my customer service connects and run its server. (Or whenever customer service connects server properly).</p>
  <p>I am aware that in the Dockerfile, we would need to add these commands to it (copying file into workdir, and run the shell script as an executable.)</p>
  <pre><code>...
  COPY wait-for-it.sh . 
  RUN chmod +x /wait-for-it.sh
  ...
  </code></pre>
  <p><strong>Here's my current Docker-Compose file</strong></p>
  <pre><code>version: '3'
  services:
    books:
      build: './books'
      container_name: &quot;horus-books&quot;
      ports:
        - &quot;30043:30043&quot;
      volumes:
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
  
    customers:
      depends_on:
        - books
      build: './customers'
      container_name: &quot;horus-customers&quot;
      ports:
        - &quot;6000:6000&quot;
      volumes:
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
  
    main:
      depends_on: 
        - customers
      build: './main'
      container_name: &quot;horus-main&quot;
      ports:
        - &quot;4555:4555&quot;
      command: [&quot;./wait-for-it.sh&quot;, &quot;customers:6000&quot;, &quot;--&quot;, &quot;node&quot;, &quot;main.js&quot;]
      volumes:
        - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
      
  </code></pre>
  <p><strong>Main Service Dockerfile</strong></p>
  <pre><code>FROM node:12.14.0
  WORKDIR /usr/src/app
  COPY package*.json ./
  COPY . /usr/src/app
  COPY wait-for-it.sh . 
  RUN chmod +x /wait-for-it.sh
  RUN npm install
  EXPOSE 4555
  CMD [&quot;node&quot;, &quot;main.js&quot;]
  </code></pre>