Docker-compose env_file behavior is confusing

I agree with @avbentem but I didn’t know I could use export before the variables. It is actually solves one of my old problems, since I wanted to parse Docker’s .env file from shell, but this way I don’t even need to.

There is something else however, that you may not know. Docker Compose v2 supports using the .env file as yaml, so you can use “:” instead of “=”. It can be useful if you prefer YAML instead of bash-like syntax. I don’t know if it is in any documentation. I discovered it by accident when I realized it was a yaml after I ran Docker Compose without error. If you use the yaml syntax, you can’t start it with export.