version: '2'

services:
  concourse-db:
    image: postgres:9.5
    volumes:
    - "${CONCOURSE_POSTGRESQL_DB_DIR}:/database"
    environment:
      POSTGRES_DB: concourse
      POSTGRES_USER: concourse
      POSTGRES_PASSWORD: changeme
      PGDATA: /database

  concourse-web:
    image: concourse/concourse
    command: web
    ports: ["8080:8080"]
    volumes:
    - "${CONCOURSE_KEYS_WEB_DIR}:/concourse-keys"
    environment:
      CONCOURSE_BASIC_AUTH_USERNAME: concourse
      CONCOURSE_BASIC_AUTH_PASSWORD: ci
      CONCOURSE_EXTERNAL_URL: "${CONCOURSE_EXTERNAL_URL}"
      CONCOURSE_POSTGRES_DATA_SOURCE: |-
        postgres://concourse:changeme@concourse-db:5432/concourse?sslmode=disable
    restart: always

  concourse-worker:
    image: concourse/concourse
    privileged: true
    command: worker
    volumes:
    - "${CONCOURSE_KEYS_WORKER_DIR}:/concourse-keys"
    - /var/run/docker.sock:/var/run/docker.sock
    environment:
      CONCOURSE_TSA_HOST: concourse-web
    restart: always

version: '2'

services:
  concourse-db:
    image: postgres:9.5
    volumes:
    - "${CONCOURSE_POSTGRESQL_DB_DIR}:/database"
    environment:
      POSTGRES_DB: concourse
      POSTGRES_USER: concourse
      POSTGRES_PASSWORD: changeme
      PGDATA: /database
    restart: always

  concourse-web:
    image: concourse/concourse
    command: web
    ports: ["8080:8080"]
    volumes:
    - "${CONCOURSE_KEYS_WEB_DIR}:/concourse-keys"
    environment:
      CONCOURSE_BASIC_AUTH_USERNAME: concourse
      CONCOURSE_BASIC_AUTH_PASSWORD: ci
      CONCOURSE_EXTERNAL_URL: "${CONCOURSE_EXTERNAL_URL}"
      CONCOURSE_POSTGRES_DATA_SOURCE: |-
        postgres://concourse:changeme@concourse-db:5432/concourse?sslmode=disable
    restart: always

  concourse-worker:
    image: concourse/concourse
    privileged: true
    command: worker
    volumes:
    - "${CONCOURSE_KEYS_WORKER_DIR}:/concourse-keys"
    - /var/run/docker.sock:/var/run/docker.sock
    environment:
      CONCOURSE_TSA_HOST: concourse-web
    restart: always

Set restart=true to db container as well
Set restart=true to db container as well
