Environment Variables aren't processed if running Docker binary normally #1332

Closed
opened 2026-02-05 00:38:43 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @DUOLabs333 on GitHub (Jul 26, 2022).

Subject of the issue

If I run vaultwarden/server:latest with source /etc/.env; /start.sh or source /etc/.etc; /vaultwarden, the new environment variables aren't used (DATA_FOLDER is still /data, and it is using a sqlite database, not my postgres one.

Deployment environment

  • vaultwarden version: 1.25.1
  • Install method: Docker image, but run manually in a chroot (the compiled version --- it's too old to show the version number at start-up --- does not have this problem).

  • Clients used:

  • Reverse proxy and version:

  • MySQL/MariaDB or PostgreSQL version:

  • Other relevant details:

Steps to reproduce

  1. Download the tar ball of the docker image
  2. Chroot into it and make an /etc/.env file with DATA_FOLDER=/etc/data.
  3. Copy /data to /etc/data.
  4. Run source /etc/.env; /start.sh.
  5. See that the data folder used is not /etc/data

Expected behaviour

The variables in /etc/.env are not respected.

Actual behaviour

Troubleshooting data

Originally created by @DUOLabs333 on GitHub (Jul 26, 2022). <!-- # ### NOTE: Please update to the latest version of vaultwarden before reporting an issue! This saves you and us a lot of time and troubleshooting. See: * https://github.com/dani-garcia/vaultwarden/issues/1180 * https://github.com/dani-garcia/vaultwarden/wiki/Updating-the-vaultwarden-image # ### --> <!-- Please fill out the following template to make solving your problem easier and faster for us. This is only a guideline. If you think that parts are unnecessary for your issue, feel free to remove them. Remember to hide/redact personal or confidential information, such as passwords, IP addresses, and DNS names as appropriate. --> ### Subject of the issue If I run `vaultwarden/server:latest` with `source /etc/.env; /start.sh` or `source /etc/.etc; /vaultwarden`, the new environment variables aren't used (`DATA_FOLDER` is still `/data`, and it is using a sqlite database, not my postgres one. ### Deployment environment <!-- ========================================================================================= Preferably, use the `Generate Support String` button on the admin page's Diagnostics tab. That will auto-generate most of the info requested in this section. ========================================================================================= --> <!-- The version number, obtained from the logs (at startup) or the admin diagnostics page --> * vaultwarden version: 1.25.1 <!-- How the server was installed: Docker image, OS package, built from source, etc. --> * Install method: Docker image, but run manually in a chroot (the compiled version --- it's too old to show the version number at start-up --- does not have this problem). * Clients used: <!-- web vault, desktop, Android, iOS, etc. (if applicable) --> * Reverse proxy and version: <!-- if applicable --> * MySQL/MariaDB or PostgreSQL version: <!-- if applicable --> * Other relevant details: ### Steps to reproduce 1. Download the tar ball of the docker image 2. Chroot into it and make an `/etc/.env` file with `DATA_FOLDER=/etc/data`. 3. Copy `/data` to `/etc/data`. 4. Run `source /etc/.env; /start.sh`. 5. See that the data folder used is not `/etc/data` ### Expected behaviour The variables in `/etc/.env` are not respected. ### Actual behaviour <!-- Tell us what actually happened --> ### Troubleshooting data <!-- Share any log files, screenshots, or other relevant troubleshooting data -->
Author
Owner

@BlackDex commented on GitHub (Jul 26, 2022):

I'm unsure what you try to do here.
If you want to use a .env file for vaultwarden to read, either mount/put that .env file in the same folder as the vaultwarden binary. Or set the ENV_FILE=/path/to/env-file before you start Vaultwarden.

Also, a source /etc/.env ; my_script.sh doesn't provide those env's to my_script.sh unless you have export VAR_NAME inside the .env file. That just not how bash or sh work, they do not have access to non-exported variables.

Also, all version of Vaultwarden/Bitwarden_RS show the version numbers during startup, and else it should be somewhere in the docker image metadata.

@BlackDex commented on GitHub (Jul 26, 2022): I'm unsure what you try to do here. If you want to use a `.env` file for vaultwarden to read, either mount/put that `.env` file in the same folder as the `vaultwarden` binary. Or set the `ENV_FILE=/path/to/env-file` before you start Vaultwarden. Also, a `source /etc/.env ; my_script.sh` doesn't provide those env's to `my_script.sh` unless you have `export VAR_NAME` inside the `.env` file. That just not how bash or sh work, they do not have access to non-exported variables. Also, all version of Vaultwarden/Bitwarden_RS show the version numbers during startup, and else it should be somewhere in the docker image metadata.
Author
Owner

@DUOLabs333 commented on GitHub (Jul 26, 2022):

I tried set -a; source /etc/.env; /vaultwarden, which should export all variables, but that didn't work either.

@DUOLabs333 commented on GitHub (Jul 26, 2022): I tried `set -a; source /etc/.env; /vaultwarden`, which should export all variables, but that didn't work either.
Author
Owner

@DUOLabs333 commented on GitHub (Jul 26, 2022):

ENV_FILE works though.

@DUOLabs333 commented on GitHub (Jul 26, 2022): `ENV_FILE` works though.
Author
Owner

@BlackDex commented on GitHub (Jul 26, 2022):

Not sure why set -a doesn't work though.
Could be the environment, could be something strange during export of all the vars compared to Vaultwarden reading the file it self. Could be the shell environment bash vs sh, or maybe even the bash/sh version it self.

Main thing is, Vaultwarden is able to read exported environment variables and read the .env file.
So, I think there is no issue.

@BlackDex commented on GitHub (Jul 26, 2022): Not sure why `set -a` doesn't work though. Could be the environment, could be something strange during export of all the vars compared to Vaultwarden reading the file it self. Could be the shell environment bash vs sh, or maybe even the bash/sh version it self. Main thing is, Vaultwarden is able to read exported environment variables and read the `.env` file. So, I think there is no issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#1332