Some variables from .env file being ignored i.e. ROCKET_PORT #512

Closed
opened 2025-10-09 16:35:36 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @RT-Tap on GitHub.

Subject of the issue

ROCKET_PORT inside .env file is ignored
possibly others - i know there was an announcement about getting rid of websockets but I did notice that the default variable mentioned in the .env.template file ENABLE_WEBSOCKET=true does not work but WEBSOCKET_ENABLE=true does work. Because it's depreciated it shouldnt matter but I figured I would mention it as well.
Others that I have changed (in the env file) and can confirm worked fine:

  • DATABASE_URL
  • PUSH_*
  • DOMAIN
  • SIGNUPS_VERIFY
  • EXPERIMENTAL_CLIENT_FEATURE_FLAGS
  • LOG_FILE
  • ADMIN_TOKEN
  • YUBICO_*
  • AUTHENTICATOR_DISBALE_TIME_DRIFT
  • SMTP_*

Deployment environment

docker compose in namespace isolated docker hence needing to use a non privileged port

  • vaultwarden version:
    docker hub image library:latest == 1.30.5
  • Install method:
    docker compose

  • Clients used:
    not applicable

  • Reverse proxy and version:
    not applicable

  • MySQL/MariaDB or PostgreSQL version:
    not applicable

  • Other relevant details:

Steps to reproduce

docker-compose.yml

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwardentest
    user: "4400:4400"
    security_opt:
      - no-new-privileges:true
    volumes:
      - "./logs/vaultwarden/:/logs/"
      - "./vaultwardendata/:/data/"
    restart: always
    secrets:
      - vaultwardenconfig
    environment:
      - ENV_FILE=/run/secrets/vaultwardenconfig
      #- ROCKET_PORT=4084   # only works when set here
    hostname: vaultwarden

secrets:
  vaultwardenconfig:
    file: ./envfile

.envfile

ROCKET_PORT=4084

Expected behaviour

Rocket server start on port 4084 when using ROCKET_PORT=4084 in env file

Actual behaviour

Rocket server still starts on port 80 unless environment variable explicitly set through docker-compose

Troubleshooting data

docker logs vaultwardentest
When set in envfile

[2024-04-12 01:38:07.039][start][INFO] Rocket has launched from http://0.0.0.0:80

when set in docker-compose environment directive

[2024-04-12 01:44:20.367][start][INFO] Rocket has launched from http://0.0.0.0:4084
Originally created by @RT-Tap on GitHub. <!-- # ### 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 <!-- Describe your issue here. --> ROCKET_PORT inside .env file is ignored possibly others - [i know there was an announcement about getting rid of websockets](https://vaultwarden.discourse.group/t/note-breaking-change-in-upcoming-v1-31-0-stable-version/3051) but I did notice that the default variable mentioned in the `.env.template` file `ENABLE_WEBSOCKET=true` does not work but `WEBSOCKET_ENABLE=true` does work. Because it's depreciated it shouldnt matter but I figured I would mention it as well. Others that I have changed (in the env file) and can confirm worked fine: - DATABASE_URL - PUSH_* - DOMAIN - SIGNUPS_VERIFY - EXPERIMENTAL_CLIENT_FEATURE_FLAGS - LOG_FILE - ADMIN_TOKEN - YUBICO_* - AUTHENTICATOR_DISBALE_TIME_DRIFT - SMTP_* ### Deployment environment docker compose in [namespace isolated docker](https://docs.docker.com/engine/security/userns-remap/) hence needing to use a non privileged port <!-- ========================================================================================= 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 --> <!-- This is NOT the version number shown on the web vault, which is versioned separately from vaultwarden --> <!-- Remember to check if your issue exists on the latest version first! --> * vaultwarden version: docker hub image library:latest == 1.30.5 <!-- How the server was installed: Docker image, OS package, built from source, etc. --> * Install method: docker compose * Clients used: <!-- web vault, desktop, Android, iOS, etc. (if applicable) --> not applicable * Reverse proxy and version: <!-- if applicable --> not applicable * MySQL/MariaDB or PostgreSQL version: <!-- if applicable --> not applicable * Other relevant details: ### Steps to reproduce <!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) and how did you start vaultwarden? --> docker-compose.yml ``` services: vaultwarden: image: vaultwarden/server:latest container_name: vaultwardentest user: "4400:4400" security_opt: - no-new-privileges:true volumes: - "./logs/vaultwarden/:/logs/" - "./vaultwardendata/:/data/" restart: always secrets: - vaultwardenconfig environment: - ENV_FILE=/run/secrets/vaultwardenconfig #- ROCKET_PORT=4084 # only works when set here hostname: vaultwarden secrets: vaultwardenconfig: file: ./envfile ``` .envfile ``` ROCKET_PORT=4084 ``` ### Expected behaviour <!-- Tell us what you expected to happen --> Rocket server start on port 4084 when using `ROCKET_PORT=4084` in env file ### Actual behaviour <!-- Tell us what actually happened --> Rocket server still starts on port 80 unless environment variable explicitly set through docker-compose ### Troubleshooting data <!-- Share any log files, screenshots, or other relevant troubleshooting data --> `docker logs vaultwardentest` When set in envfile ``` [2024-04-12 01:38:07.039][start][INFO] Rocket has launched from http://0.0.0.0:80 ``` when set in docker-compose environment directive ``` [2024-04-12 01:44:20.367][start][INFO] Rocket has launched from http://0.0.0.0:4084 ```
Author
Owner

@BlackDex commented on GitHub:

I do not think we can fix this. The env's are loaded in a order, and the one which is last will probably override the previously set items.

The problem here is that the env of the container it self is not overridden when loading the .env file.
It currently checks if there already is an env value assigned, if so, it will not re-assign.
The reason a -e or custom environment setting works is that it will override the default container environment.

The only way we could solve this is by changing from_path to from_path_override, but that probably would be a breaking change as it might cause issues for other users.

So, it's not really an issue, as this is how it is designed.

@BlackDex commented on GitHub: I do not think we can fix this. The env's are loaded in a order, and the one which is last will probably override the previously set items. The problem here is that the env of the container it self is not overridden when loading the .env file. It currently checks if there already is an env value assigned, if so, it will not re-assign. The reason a `-e` or custom `environment` setting works is that it will override the default container environment. The only way we could solve this is by changing `from_path` to `from_path_override`, but that probably would be a breaking change as it might cause issues for other users. So, it's not really an issue, as this is how it is designed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#512