Understanding Mapping vs List Syntax for Environment Variables

0
1
Asked By CuriousCoder42 On

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.

2 Answers

Answered By DocuMentor88 On

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!

Answered By SyntaxSavvy99 On

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!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.