title: Docker container for app tests with postgres database
body: <p>I'm new to Docker.</p>
  
  <p>I'm trying to run my node app tests in a Docker container. 
  I want to run the tests with a real postgres db.
  I'm creating this container with the following Dockerfile:</p>
  
  <pre><code># Set image
  FROM postgres:alpine
  # Install node latest
  RUN apk add --update nodejs nodejs-npm
  # Set working dir
  WORKDIR .
  # Copy the current directory contents into the container at .
  ADD src src
  ADD .env.testing .env
  ADD package.json .
  ADD package-lock.json .
  
  # Run tests
  CMD npm install &amp;&amp; npm run coverage
  </code></pre>
  
  <ol>
  <li><p>From the image docs, when I run the container with:</p>
  
  <p>$ docker run build-name -d postgres</p></li>
  </ol>
  
  <p>I see that the container takes time to start postgresql service.</p>
  
  <ol start="2">
  <li><p>When I run the container without the "-d postgres" param:</p>
  
  <p>$ docker run build-name</p></li>
  </ol>
  
  <p>The service does not start and the tests fail due to "could not connect to server".</p>
  
  <hr>
  
  <p>Questions:</p>
  
  <p>A. How can I run the tests AFTER the postgresql service starts?</p>
  
  <p>B. I saw some examples using docker-composer but can I do this without composer?</p>
  
  <p>Thanks</p>