Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot send emails using docker run #2533

Closed
1 task done
Tracked by #2480
GieltjE opened this issue Jan 2, 2023 · 14 comments
Closed
1 task done
Tracked by #2480

Cannot send emails using docker run #2533

GieltjE opened this issue Jan 2, 2023 · 14 comments
Labels
bug bw-unified-deploy An Issue related to Bitwarden unified deployment

Comments

@GieltjE
Copy link

GieltjE commented Jan 2, 2023

Steps To Reproduce

1: install using docker compose up, verify that /admin sends the email correctly
2: docker rm bitwarden-bitwarden-1 (gets a funny name using docker compose up, this is the only discernable difference)
3: start it using the alternative method (e.g. docker run -d --name bitwarden -v C:\Users\MichielHazelhof\Desktop\bitwarden\bwdata:/etc/bitwarden -p 80:8080 --env-file settings.env bitwarden/self-host:beta)
4: attempt to get the email from /admin

Expected Result

Emails should always arive and if they don't a log should be generated

Actual Result

No email is sent (no logs on the mailserver) and no local failure log is generated

Screenshots or Videos

No response

Additional Context

No response

Githash Version

455d62e-dirty

Environment Details

  • OS: Win 11 insider
  • Env: Docker
  • Hardware: 3700X 64GB ram

Database Image

Mariadb: 10.10.2

Issue-Link

#2480

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@GieltjE GieltjE added bug bw-unified-deploy An Issue related to Bitwarden unified deployment labels Jan 2, 2023
@justindbaur
Copy link
Member

Apologies if this is what you mean by "local failure log" but do you have any error messages in /var/log/bitwarden/admin.log?

@GieltjE
Copy link
Author

GieltjE commented Jan 2, 2023

The admin.log doesn't display anything, the call to http://localhost/admin/login is much, much faster too.

@GieltjE
Copy link
Author

GieltjE commented Jan 3, 2023

On a side note, the example docker-compose.yaml (https://github.com/bitwarden/server/blob/master/docker-unified/docker-compose.yml) contains a mount path for the logs.

The docker run example (https://bitwarden.com/help/install-and-deploy-unified-beta/#using-docker-run) does not.

@kspearrin
Copy link
Member

Did you configure a mail server in your env vars?

@GieltjE
Copy link
Author

GieltjE commented Jan 6, 2023

Yes, using "docker compose up" with the same settings.env file works just fine, docker even reports the same env variables.

@kspearrin
Copy link
Member

There should be no difference as long as you are using the correct command. Are you sure you don't need to specify a more absolute path to the settings.env?

@GieltjE
Copy link
Author

GieltjE commented Jan 7, 2023

docker run -d --name bitwarden -v C:\Users\MichielHazelhof\Desktop\bitwarden\logs:/var/log/bitwarden -v C:\Users\MichielHazelhof\Desktop\bitwarden\bwdata:/etc/bitwarden -p 80:8080 --env-file C:\Users\MichielHazelhof\Desktop\bitwarden\settings.env bitwarden/self-host:beta

docker-compose.yml

version: "3.8"

services:
  bitwarden:
    env_file:
      - C:\Users\MichielHazelhof\Desktop\bitwarden\settings.env
    image: bitwarden/self-host:beta
    restart: always
    ports:
      - "80:8080"
    volumes:
      - C:\Users\MichielHazelhof\Desktop\bitwarden\bwdata:/etc/bitwarden
      - C:\Users\MichielHazelhof\Desktop\bitwarden\logs:/var/log/bitwarden

volumes:
  bitwarden:
  data:

The first will absuletely not send emails, the second one does so without a hitch.

@DonSYS91
Copy link

I can confirm that docker run is not sending mails.
I have nearly the same environment as @GieltjE with Docker Desktop but Windows 10.

I can also confirm that settings.env is being found correctly and set by Docker while checking using inspect also using Postgres which works fine so settings.env is definitely parsed.

I also noticed that the setting to disable User Registrations is being ignored so it looks like all settings with globalSettings are being ignored including mail:

#globalSettings__mail__replyToEmail=noreply@$BW_DOMAIN
#globalSettings__mail__smtp__host=smtphost.example.com
#globalSettings__mail__smtp__port=587
#globalSettings__mail__smtp__ssl=false
#globalSettings__mail__smtp__username=smtpusername
#globalSettings__mail__smtp__password=smtppassword

# Yubikey
#globalSettings__yubico__clientId=REPLACE
#globalSettings__yubico__key=REPLACE

# Other
#globalSettings__disableUserRegistration=false
#globalSettings__hibpApiKey=REPLACE
#adminSettings__admins="[email protected],[email protected]"``

@kspearrin
Copy link
Member

Can you exec the env command on the container and see if the env vars are even loaded?

docker exec -it bitwarden env

@GieltjE
Copy link
Author

GieltjE commented Jan 16, 2023

docker run

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=xxx
TERM=xterm
BW_DOMAIN=localhost
BW_DB_PROVIDER=mariadb
BW_DB_SERVER=192.168.178.88
BW_DB_DATABASE=bitwarden_vault
BW_DB_USERNAME=root
BW_DB_PASSWORD=xxx
BW_INSTALLATION_ID=xxx
BW_INSTALLATION_KEY=xxx
BW_ENABLE_SSL=false
globalSettings__mail__replyToEmail=xxx
globalSettings__mail__smtp__host=xxx
globalSettings__mail__smtp__port=xxx
globalSettings__mail__smtp__ssl=false
globalSettings__mail__smtp__username=xxx
globalSettings__mail__smtp__password=xxx
globalSettings__disableUserRegistration=false
adminSettings__admins="xxx"
ASPNETCORE_URLS=http://+:80
DOTNET_RUNNING_IN_CONTAINER=true
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
DOTNET_VERSION=6.0.12
ASPNET_VERSION=6.0.12
ASPNETCORE_ENVIRONMENT=Production
BW_ENABLE_ADMIN=true
BW_ENABLE_API=true
BW_ENABLE_EVENTS=false
BW_ENABLE_ICONS=true
BW_ENABLE_IDENTITY=true
BW_ENABLE_NOTIFICATIONS=true
BW_ENABLE_SCIM=false
BW_ENABLE_SSO=false
BW_DB_FILE=/etc/bitwarden/vault.db
globalSettings__selfHosted=true
globalSettings__pushRelayBaseUri=https://push.bitwarden.com
globalSettings__baseServiceUri__internalAdmin=http://localhost:5000
globalSettings__baseServiceUri__internalApi=http://localhost:5001
globalSettings__baseServiceUri__internalEvents=http://localhost:5003
globalSettings__baseServiceUri__internalIcons=http://localhost:5004
globalSettings__baseServiceUri__internalIdentity=http://localhost:5005
globalSettings__baseServiceUri__internalNotifications=http://localhost:5006
globalSettings__baseServiceUri__internalSso=http://localhost:5007
globalSettings__baseServiceUri__internalScim=http://localhost:5002
globalSettings__baseServiceUri__internalVault=http://localhost:80
globalSettings__identityServer__certificatePassword=default_cert_password
globalSettings__dataProtection__directory=/etc/bitwarden/data-protection
globalSettings__attachment__baseDirectory=/etc/bitwarden/attachments
globalSettings__send__baseDirectory=/etc/bitwarden/attachments/send
globalSettings__licenseDirectory=/etc/bitwarden/licenses
globalSettings__logDirectoryByProject=false
globalSettings__logRollBySizeLimit=1073741824
HOME=/root

docker compose up

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=xxx
TERM=xterm
globalSettings__mail__smtp__port=xxx
BW_DB_DATABASE=bitwarden_vault
BW_DB_USERNAME=root
BW_INSTALLATION_KEY=xxx
globalSettings__mail__smtp__host=xxx
globalSettings__mail__smtp__password=xxx
globalSettings__mail__replyToEmail=xxx
adminSettings__admins=xxx
globalSettings__mail__smtp__username=xxx
BW_DB_PASSWORD=xxx
BW_DB_SERVER=192.168.178.88
globalSettings__mail__smtp__ssl=false
BW_INSTALLATION_ID=xxx
globalSettings__disableUserRegistration=false
BW_DB_PROVIDER=mariadb
BW_DOMAIN=localhost
BW_ENABLE_SSL=false
ASPNETCORE_URLS=http://+:80
DOTNET_RUNNING_IN_CONTAINER=true
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
DOTNET_VERSION=6.0.12
ASPNET_VERSION=6.0.12
ASPNETCORE_ENVIRONMENT=Production
BW_ENABLE_ADMIN=true
BW_ENABLE_API=true
BW_ENABLE_EVENTS=false
BW_ENABLE_ICONS=true
BW_ENABLE_IDENTITY=true
BW_ENABLE_NOTIFICATIONS=true
BW_ENABLE_SCIM=false
BW_ENABLE_SSO=false
BW_DB_FILE=/etc/bitwarden/vault.db
globalSettings__selfHosted=true
globalSettings__pushRelayBaseUri=https://push.bitwarden.com
globalSettings__baseServiceUri__internalAdmin=http://localhost:5000
globalSettings__baseServiceUri__internalApi=http://localhost:5001
globalSettings__baseServiceUri__internalEvents=http://localhost:5003
globalSettings__baseServiceUri__internalIcons=http://localhost:5004
globalSettings__baseServiceUri__internalIdentity=http://localhost:5005
globalSettings__baseServiceUri__internalNotifications=http://localhost:5006
globalSettings__baseServiceUri__internalSso=http://localhost:5007
globalSettings__baseServiceUri__internalScim=http://localhost:5002
globalSettings__baseServiceUri__internalVault=http://localhost:80
globalSettings__identityServer__certificatePassword=default_cert_password
globalSettings__dataProtection__directory=/etc/bitwarden/data-protection
globalSettings__attachment__baseDirectory=/etc/bitwarden/attachments
globalSettings__send__baseDirectory=/etc/bitwarden/attachments/send
globalSettings__licenseDirectory=/etc/bitwarden/licenses
globalSettings__logDirectoryByProject=false
globalSettings__logRollBySizeLimit=1073741824
HOME=/root

After sorting both the only differences are the HOSTNAME and the double quotes around the adminSettings__admins variable (content is otherwise the same).

@ghost
Copy link

ghost commented Jan 22, 2023

Probably the same issue as #2572.

@kspearrin
Copy link
Member

Can you try removing the quotes from the admin email settings, as discussed here: #2572

@GieltjE
Copy link
Author

GieltjE commented Jan 23, 2023

Can you try removing the quotes from the admin email settings, as discussed here: #2572

That indeed fixes the issue, will the documentation be updated or will the container be updated to support this behaviour (or both?).

@kspearrin
Copy link
Member

Great. The referenced PR updates the example used in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bw-unified-deploy An Issue related to Bitwarden unified deployment
Projects
None yet
Development

No branches or pull requests

4 participants