title: Docker: Why does wait-for always time out?
body: <p><a href="https://docs.docker.com/compose/startup-order/" rel="noreferrer">This page</a> discusses how to control startup order using docker-compose. It recommends three tools: <em>wait-for-it</em>, <em>dockerize</em> or <em>wait-for</em>.</p>
  
  <p>I have struggled to get either <em>wait-for-it</em> or <em>wait-for</em> working as expected, but in this question I'll focus on <em><a href="https://github.com/Eficode/wait-for" rel="noreferrer">wait-for</a></em>.  </p>
  
  <p>Each time my docker container starts, it quits with "Operation Timed Out".</p>
  
  <p>Here's my very simple docker file as an example:  </p>
  
  <pre><code>FROM ubuntu
  
  COPY ./wait-for.sh /
  WORKDIR /
  RUN chmod +x ./wait-for.sh
  CMD sh -c './wait-for.sh www.eficode.com:80 -- echo "Eficode site is up"'
  </code></pre>
  
  <p>This should copy the script from the current directory to the root, make it executable and set the run command to execute the script and check the status of the eficode website (example taken from the eficode github page).</p>
  
  <p><a href="https://i.stack.imgur.com/wJWDY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wJWDY.png" alt="Image showing the error message"></a></p>
  
  <p>I've tried supplying the timeout flag, which does adjust the timeout, but doesn't affect the result. I've also tried running this script as part of a docker-compose command (following the example on the docker-compose documentation page linked above) but, again, with the same result.</p>
  
  <p>What am I doing wrong?</p>