GitBook: [#53] Add note re env_file usage in Swarm

ce-2.11
James Carppe 2022-05-02 00:42:01 +00:00 committed by gitbook-bot
parent f1aaf5aced
commit 4ab0366ae9
No known key found for this signature in database
GPG Key ID: 07D2180C7B12D0FF
1 changed files with 3 additions and 1 deletions

View File

@ -26,13 +26,15 @@ environment:
- MY_ENVIRONMENT_VARIABLE: ${MY_ENVIRONMENT_VARIABLE}
```
Alternatively, you can add `stack.env` as an `env_file` definition to add all the environment variables that you have defined individually as well as those included in an uploaded .env file:
Alternatively, on Docker Standalone environments you can add `stack.env` as an `env_file` definition to add all the environment variables that you have defined individually as well as those included in an uploaded .env file:
```
env_file:
- stack.env
```
**Note:** Using `env_file` to define a file does not work in Docker Swarm due to the lack of `env_file` support in `docker stack deploy` (used on Swarm environments to deploy your stack). On Docker Swarm, you will need to define each environment variable manually. 
{% hint style="info" %}
Note the compose file is not changed when environment variables are used - this allows variables to be updated within Portainer without editing the compose file itself. You will still see the `${MY_ENVIRONMENT_VARIABLE}` style entry in the compose file.
{% endhint %}