diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/docker/compose%2Fenv-file%2Findex.html | |
new repository
Diffstat (limited to 'devdocs/docker/compose%2Fenv-file%2Findex.html')
| -rw-r--r-- | devdocs/docker/compose%2Fenv-file%2Findex.html | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/devdocs/docker/compose%2Fenv-file%2Findex.html b/devdocs/docker/compose%2Fenv-file%2Findex.html new file mode 100644 index 00000000..c0abc37d --- /dev/null +++ b/devdocs/docker/compose%2Fenv-file%2Findex.html @@ -0,0 +1,11 @@ +<h1>Declare default environment variables in file</h1> + +<p>Compose supports declaring default environment variables in an environment file named <code class="language-plaintext highlighter-rouge">.env</code> placed in the project directory. Docker Compose versions earlier than <code class="language-plaintext highlighter-rouge">1.28</code>, load the <code class="language-plaintext highlighter-rouge">.env</code> file from the current working directory, where the command is executed, or from the project directory if this is explicitly set with the <code class="language-plaintext highlighter-rouge">--project-directory</code> option. This inconsistency has been addressed starting with <code class="language-plaintext highlighter-rouge">+v1.28</code> by limiting the default <code class="language-plaintext highlighter-rouge">.env</code> file path to the project directory. You can use the <code class="language-plaintext highlighter-rouge">--env-file</code> commandline option to override the default <code class="language-plaintext highlighter-rouge">.env</code> and specify the path to a custom environment file.</p> <p>The project directory is specified by the order of precedence:</p> <ul> <li> +<code class="language-plaintext highlighter-rouge">--project-directory</code> flag</li> <li>Folder of the first <code class="language-plaintext highlighter-rouge">--file</code> flag</li> <li>Current directory</li> </ul> <h2 id="syntax-rules">Syntax rules</h2> <p>The following syntax rules apply to the <code class="language-plaintext highlighter-rouge">.env</code> file:</p> <ul> <li>Compose expects each line in an <code class="language-plaintext highlighter-rouge">env</code> file to be in <code class="language-plaintext highlighter-rouge">VAR=VAL</code> format.</li> <li>Lines beginning with <code class="language-plaintext highlighter-rouge">#</code> are processed as comments and ignored.</li> <li>Blank lines are ignored.</li> <li>There is no special handling of quotation marks. This means that <strong>they are part of the VAL</strong>.</li> </ul> <h2 id="compose-file-and-cli-variables">Compose file and CLI variables</h2> <p>The environment variables you define here are used for <a href="../compose-file/compose-file-v3/index#variable-substitution">variable substitution</a> in your Compose file, and can also be used to define the following <a href="../reference/envvars/index">CLI variables</a>:</p> <ul> <li><code class="language-plaintext highlighter-rouge">COMPOSE_API_VERSION</code></li> <li><code class="language-plaintext highlighter-rouge">COMPOSE_CONVERT_WINDOWS_PATHS</code></li> <li><code class="language-plaintext highlighter-rouge">COMPOSE_FILE</code></li> <li><code class="language-plaintext highlighter-rouge">COMPOSE_HTTP_TIMEOUT</code></li> <li><code class="language-plaintext highlighter-rouge">COMPOSE_PROFILES</code></li> <li><code class="language-plaintext highlighter-rouge">COMPOSE_PROJECT_NAME</code></li> <li><code class="language-plaintext highlighter-rouge">COMPOSE_TLS_VERSION</code></li> <li><code class="language-plaintext highlighter-rouge">DOCKER_CERT_PATH</code></li> <li><code class="language-plaintext highlighter-rouge">DOCKER_HOST</code></li> <li><code class="language-plaintext highlighter-rouge">DOCKER_TLS_VERIFY</code></li> </ul> <blockquote> <p><strong>Notes</strong></p> <ul> <li>Values present in the environment at runtime always override those defined inside the <code class="language-plaintext highlighter-rouge">.env</code> file. Similarly, values passed via command-line arguments take precedence as well.</li> <li>Environment variables defined in the <code class="language-plaintext highlighter-rouge">.env</code> file are not automatically visible inside containers. To set container-applicable environment variables, follow the guidelines in the topic <a href="../environment-variables/index">Environment variables in Compose</a>, which describes how to pass shell environment variables through to containers, define environment variables in Compose files, and more.</li> </ul> </blockquote> <h2 id="more-compose-documentation">More Compose documentation</h2> <ul> <li><a href="../index">User guide</a></li> <li><a href="../install/index">Installing Compose</a></li> <li><a href="../gettingstarted/index">Getting Started</a></li> <li><a href="../reference/index">Command line reference</a></li> <li><a href="../compose-file/index">Compose file reference</a></li> <li><a href="../samples-for-compose/index">Sample apps with Compose</a></li> </ul> +<p><a href="https://docs.docker.com/search/?q=fig">fig</a>, <a href="https://docs.docker.com/search/?q=composition">composition</a>, <a href="https://docs.docker.com/search/?q=compose">compose</a>, <a href="https://docs.docker.com/search/?q=docker">docker</a>, <a href="https://docs.docker.com/search/?q=orchestration">orchestration</a>, <a href="https://docs.docker.com/search/?q=environment">environment</a>, <a href="https://docs.docker.com/search/?q=env%20file">env file</a></p> +<div class="_attribution"> + <p class="_attribution-p"> + © 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br> + <a href="https://docs.docker.com/compose/env-file/" class="_attribution-link">https://docs.docker.com/compose/env-file/</a> + </p> +</div> |
