Ghost is apparently not reading environment variables (using Docker)

Hello. Thank you for the amazing piece of software and tooling :slight_smile:

We have a Ghost instance running on Digital Ocean. We are starting it with Docker/Podman. The environment variables seem to be passed to the container, but not read by Ghost itself.

For example, running env inside the running container prints:

mail__transport=SMTP
GHOST_VERSION=5.121.0
...

because we have the following docker-compose.yaml

...
ghost:
    container_name: ghost
    image: ghost:latest
    restart: always
    environment:
      url: https://${GHOST_DOMAIN}

      mail__transport: SMTP
...

However, running ghost config mail.transport prints

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org


Direct

Because of this, we cannot send transactional emails, and thus I cannot login (due to the new feature of demanding that staff users get an email when logging in).

Are we doing something wrong? Thanks!

As far as I understand, ghost config [key] does not return environment variables. Just tried it on a running site that definitely has stuff set (e.g. url) and I am getting the same result as you.

So, the issue is rather with the mail setup itself. The fact that ghost config [key] does not return anything is a red herring.

How does the rest of the mail configuration look like? Has this worked before?
As an alternative, if you need to log in quickly, have a look here at the security config:

Hello Jannis. That helps definitely.

I have disabled that and logged in successfuly :slight_smile:

It has worked in the past.

The rest looks like this:

mail__options__secure=True
mail__options__auth__user=geral@d**o.pt
mail__transport=SMTP
mail__options__port=465
mail__from='***' <geral@d**o.pt>
mail__options__auth__pass=***
mail__options__host=mail.d**o.pt

With “***” being just redacted stuff, that should be correct. We have also tried using Mailgun, with no success. We will try again later, but it should be working, I think.

Glad to hear it’s working!

In production, the mail setup is required (meaning, if new features are added, Ghost assumes that you have a working mail setup for production), so you should figure that out.

What I’d check is if the exact SMTP credentials work elsewhere. Then work from there.

1 Like

Bingo. That’s your problem. DO is blocking outbound SMTP. Switch to port 2525 (not blocked by DO recently at least), or switch to using a mail service that’ll accept email via API.

1 Like

Not having to deal with DO myself, I always forget about that. Good point! :upside_down_face:

1 Like

I don’t use DO either, I’ve just seen it enough times!

1 Like