title: Run mocha unit-test on docker-compose images
body: <p>I have an api in nodeJs, which run under micro-services.
  So far it work, what i want to do next is to be able to run unit-test (mocha) on those images.</p>
  
  <p>docker-compose.yml:</p>
  
  <pre><code>version: '3'
  
  services:   db:
      image: mongo
      ports:
        - 27017:27017
  
    db-seeds:
      build: ./services/mongo-seeds
      links:
        - db
  
    gateway:
      build: ./services/gateway
      ports:
        - 4000:4000
      depends_on:
        - A
        - B
        - C
  
    A:
      build: ./services/A
      ports:
        - 4003:4000
      depends_on:
        - db
  
    B:
      build: ./services/B
      ports:
        - 4001:4000
      depends_on:
        - db
  
    C:
      build: ./services/C
      ports:
        - 4002:4000
      depends_on:
        - db
  </code></pre>
  
  <p>One of a DockerFile:</p>
  
  <pre><code>FROM node:latest
  COPY . /src
  WORKDIR /src
  RUN yarn
  EXPOSE 4000
  CMD yarn start
  </code></pre>
  
  <p>What i did so far is to make another docker-compose file which will run other docker file (DockerFile.test) :</p>
  
  <pre><code>FROM node:latest
  COPY . /src
  WORKDIR /src
  RUN yarn
  EXPOSE 4000
  CMD yarn test
  </code></pre>
  
  <p>also tried: </p>
  
  <pre><code>FROM node:latest
  COPY . /src
  WORKDIR /src
  RUN yarn
  EXPOSE 4000
  CMD yarn start
  RUN sleep 240
  CMD yarn test
  </code></pre>
  
  <p>They both fail, at this point yarn test is launch before my gateway and servers are up. What i want to do, is to launch my servers and then run my unit-test in the images, but i'm new to docker and lack knowledge on how to implement that.</p>
  
  <p>yarn test:     </p>
  
  <blockquote>
    <p>"test": "NODE_ENV=test ./node_modules/.bin/mocha"</p>
  </blockquote>