Skip to content

how to use the env-file with docker compose #5445

Answered by bytebone
Piepe6213 asked this question in Q&A
Discussion options

You must be logged in to vote

In Docker Compose, there are two ways to define environment variables:

  1. You can set them directly in the compose file under the env property
  2. Or you can refer to a separate file (conventially called .env but you can do whatever you like) where you store all the data you want.

An example for approach 1:

services:
  vaultwarden:
    env:
      - ADMIN_TOKEN="yourtokenhere"

And an example for approach 2:

services:
  vaultwarden:
    env_file: .env

with the .env file being a plain text file like this:

ADMIN_TOKEN="yourtokenhere"

The .env file, in this case, would have to be saved in the same place as the compose.yml file. As you can see, the syntax between defining in the compose file and in…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@Piepe6213
Comment options

@smile2008
Comment options

@stefan0xC
Comment options

@smile2008
Comment options

Comment options

You must be logged in to vote
2 replies
@smile2008
Comment options

@bytebone
Comment options

Answer selected by Piepe6213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants