Can I use a .env file with docker?

Hello!

I’m new to vaultwarden and docker. I have vaultwarden running, but I have a few questions.

I started vaultwarden with:

docker run --detach --name vaultwarden   --env DOMAIN="https://<redacted>"   --volume /data/vw-data/:/data/   --restart unless-stopped   --publish 80:80   --env ADMIN_TOKEN=<redacted> --env SMTP_DEBUG=TRUE --env LOG_LEVEL=debug --env EXTENDED_LOGGING=true  vaultwarden/server:latest

How can I use a file to hold these environmental variables. There’s more things I’d like to do, but I’d rather have a config file rather than a cluttered command line that seems prone to error.

Also, more of a docker thing than vaultwarden, but I’d like to relocate the volume on the host that the vaultwarden /data maps to. How can I do this? For now I just stopped the container, moved the directory, and used a symlink. I just don’t want that to be the permanent solution.

Thanks!

I use docker with an .env file, like:

docker run --rm \
  -p 127.0.0.1:30317:80 \
  --env-file $CONFIG -v $STATE:/data/ \
  --name $CONTAINER $IMAGE 1> /dev/null

where CONFIG=/path/to/env/file

(docker run --help shows the --env and --env-file options BTW).

Thanks! I simply overlooked that when checking options. Works well.