Ahmed Nawaz Khan
Ahmed Nawaz Khan

Reputation: 1796

Docker compose file global restart policy

Can I define a global restart policy on all the containers inside of a single docker-compose file instead of adding it individually in each service?

Upvotes: 1

Views: 198

Answers (1)

anemyte
anemyte

Reputation: 20196

As already pointed out by @larsks, there is no such feature yet. But it is possible (since version 3.4) to define common properties using x- keys and avoid repetition using YAML merge syntax:

version: "3.9"
x-common-options:
  &common-options
  restart: always
  logging:
    options:
      max-size: '12m'
      max-file: '5'
    driver: json-file

services:
  service_one:
    << : *common-options
    image: image1

The above is the same as this:

version: "3.9"
services:
  service_one:
    image: image1
    restart: always
    logging:
      options:
        max-size: '12m'
        max-file: '5'
      driver: json-file

Upvotes: 1

Related Questions