harshadbhatia
harshadbhatia

Reputation: 234

Docker Compose Syntax

so I have been using docker compose for a while, I have recently come across this new syntax and I have no idea what it means:

For example - the compose file is located here

http://airflow.apache.org/docs/apache-airflow/stable/docker-compose.yaml

It has things such as

Could somebody explain to me what that means ? It appears to be some defining config and referencing it.

Upvotes: 1

Views: 106

Answers (1)

anemyte
anemyte

Reputation: 20196

This isn't Docker feature, this is YAML merge syntax to help you DRY. &airflow-common declares an anchor for the contents after it, <<: *airflow-common merges contents below with the contents of the anchor. See the example:

---
- &CENTER { x: 1, y: 2 }
- &LEFT { x: 0, y: 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }

# All the following maps are equal:

- # Explicit keys
  x: 1
  y: 2
  r: 10
  label: center/big

- # Merge one map
  << : *CENTER
  r: 10
  label: center/big

- # Merge multiple maps
  << : [ *CENTER, *BIG ]
  label: center/big

- # Override
  << : [ *BIG, *LEFT, *SMALL ]
  x: 1
  label: center/big

Upvotes: 1

Related Questions