title: Restart Docker Containers when they Crash Automatically
body: <p>I want to restart a container if it crashes automatically.  I am not sure how to go about doing this.  I have a script docker-compose-deps.yml that has elasticsearch, redis, nats, and mongo.  I run this in the terminal to set this up: <code>docker-compose -f docker-compose-deps.yml up -d</code>.  After this I set up my containers by running: <code>docker-compose up -d</code>.  Is there a way to make these containers restart if they crash?  I noticed that docker has a built in restart, but I don't know how to implement this.</p>
  
  <p>After some feedback I added <code>restart: always</code> to my <code>docker-compose</code> file and my <code>docker-compose-deps.yml</code> file.  Does this look correct?  Or is this how you would implement the restart always?</p>
  
  <p>docker-compose sample</p>
  
  <pre><code>myproject-server:
    build: "../myproject-server"
    dockerfile: Dockerfile-dev
    restart: always
    ports:
    - 5880:5880
    - 6971:6971
    volumes:
    - "../myproject-server/src:/src"
    working_dir: "/src"
    external_links:
    - nats
    - mongo
   - elasticsearch
   - redis
  myproject-associate:
    build: "../myproject-associate"
    dockerfile: Dockerfile-dev
    restart: always
    ports:
    - 5870:5870
    volumes:
    - "../myproject-associate/src:/src"
    working_dir: "/src"
    external_links:
    - nats
    - mongo
    - elasticsearch
    - redis
  </code></pre>
  
  <p>docker-compose-deps.yml sample</p>
  
  <pre><code>nats:
    image: nats
    container_name: nats
    restart: always
    ports:
    - 4222:4222
  mongo:
    image: mongo
    container_name: mongo
    restart: always
    volumes:
    - "./data:/data"
    ports:
    - 27017:27017
  </code></pre>