Understanding Mapping vs List Syntax for Environment Variables
Asked by
waiting for spring
Hey everyone! I have a bit of a silly question about setting environment variables. I know that you can use either mapping syntax or list syntax to do this. For example, setting an environment variable like this:
environment:
ORIGIN: 'https://whatever.org'
is equivalent to this:
environment:
- ORIGIN = https://whatever.org
But I'm curious, is this true for most instances? Specifically, can I use both syntaxes for PUID and GUID? I've only ever used the list syntax, and I'd really prefer to stick with just one style.
Answers
To clarify, one syntax is more like a dictionary format (the first one you mentioned) while the other is an array style (list). You can represent items with a dash for the list, and the dictionary format uses key: value pairs. This means you can have keys pointing to values that could eventually lead to other mappings too. As for PUID and GUID, yes, you can definitely use both syntaxes for them!
Reply to this answer
You can check the official Docker documentation for environment variables. But just to answer your question directly, both mapping and list syntax work for setting environment variables like PUID and GUID. Just be cautious with how you format them!
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions