I see something like
celerybeat:
<<: *django
in https://github.com/pydanny/cookiecutter-django example docker files.
What does it mean? I can't google <<: *
Docker-Compose Django. Docker Compose. Conclusion. Docker is an open-source platform, and it makes it easy and possible to develop, run, and ship allocated applications with the help of a well-defined set of rules in controlled and distributed environments as a containerization platform.
In the Dockerfile spec the backslash is used as an escape character, and also for line continuation.
<<
and *
are both YAML keys (you can also think of them as operators). And one more key related to your question is &
.
In YAML, you can define anchors and later use them. For example,
foo: &myanchor
key1: "val1"
key2: "val2"
bar: *myanchor
In this code snippet, &
defines an anchor names it myanchor
, and *myanchor
references that anchor. Now both foo
and bar
have the same keys and values.
<<
is called the YAML merge key. You can compare it to class inheritance in OOP (not so accurate, but can help you understand). See below example.
foo: &myanchor
key1: "val1"
key2: "val2"
bar:
<< : *myanchor
key2: "val2-new"
key3: "val3"
In this code snippet, we merge keys and values from foo
to bar
but override the key2
to a new value. And we add a new key-value pair to bar
.
Now bar
has the following value: {"bar": {"key1": "val1", "key2": val2-new", "key3": "val3"}}
.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With