docker-compose files use YAML syntax. Those characters are YAML syntax for "anchors" and "aliaes", which are basically ways of referring to one section of the YAML document from another section of the document. For example, consider this example:
example:
list1: &foo
- one
- two
list2: *foo
That defines an anchor named foo
referring to the list in the list1
key. Elsewhere in the document we can use *foo
to refer to that same list.
If you paste that into an online yaml parser, you will find that the resulting data structures looks as if list2
was specified with the same content as list1
:
{
"example": {
"list1": [
"one",
"two"
],
"list2": [
"one",
"two"
]
}
}
This is useful in a docker-compose.yaml
file if you have a common set of volumes or networks, etc, that you want to include in several service definitions.
You can read more about this in the Wikipedia YAML article.