# Passing email API key to container without hardcoding in app.yml

**URL:** https://meta.discourse.org/t/passing-email-api-key-to-container-without-hardcoding-in-app-yml/349002
**Category:** Support
**Created:** [January 25, 2025, 10:43pm UTC](https://meta.discourse.org/t/passing-email-api-key-to-container-without-hardcoding-in-app-yml/349002 "2025-01-25T22:43:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![0xDBFB7](https://avatars.discourse-cdn.com/v4/letter/0/53a042/32.png) [@0xDBFB7](https://meta.discourse.org/u/0xDBFB7)
#### Post date: [January 25, 2025, 10:43pm UTC](https://meta.discourse.org/t/passing-email-api-key-to-container-without-hardcoding-in-app-yml/349002/1 "2025-01-25T22:43:46Z")

</div>

Howdy! I have the discourse configuration app.yml tracked in a git repository (together with the rest of the server’s configuration).

Naturally, I would like to keep the `DISCOURSE_SMTP_PASSWORD` out of the git repo, so I want to pass it in separately. Is there a recommended way to do this?

I’ve tried:

Using docker-compose’s `env_file:` section, together with the `env:`, to try to pass in a separate file:

```plaintext
env_file:
  - path: /var/discourse/containers/creds.env

env:
  LANG: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en
  ...

====== creds.env ======
DISCOURSE_SMTP_PASSWORD="..."

```

but I haven’t been able to get docker to pick up the ENV var.

I tried passing it to ``–docker-args```,  
`sudo /var/discourse/launcher rebuild app --docker-args DISCOURSE_SMTP_PASSWORD=$DISCOURSE_SMTP_PASSWORD`  
But that borks immediately:  
`docker: invalid reference format: repository name must be lowercase.`

Thank you for this wonderful software and I hope you’re all keeping safe :)))

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [January 25, 2025, 11:36pm UTC](https://meta.discourse.org/t/passing-email-api-key-to-container-without-hardcoding-in-app-yml/349002/2 "2025-01-25T23:36:24Z")

</div>

Hey, welcome back!

I believe the right syntax would be something like:

```plaintext
./launcher rebuild app --docker-args "-e DISCOURSE_SMTP_PASSWORD=\"password\""

```

With `--env-file`, this should work as well:

```plaintext
./launcher rebuild app --docker-args "--env-file=/var/discourse/containers/creds.env"

```

---

<div class="post-metadata">

### Author: ![0xDBFB7](https://avatars.discourse-cdn.com/v4/letter/0/53a042/32.png) [@0xDBFB7](https://meta.discourse.org/u/0xDBFB7)
#### Post date: [January 26, 2025, 5:12pm UTC](https://meta.discourse.org/t/passing-email-api-key-to-container-without-hardcoding-in-app-yml/349002/3 "2025-01-26T17:12:51Z")

</div>

That worked great!

(for posterity: I needed to tweak the quoting a bit as well, like so:

```plaintext
./launcher rebuild app --docker-args "-e DISCOURSE_SMTP_PASSWORD=$DISCOURSE_SMTP_PASSWORD"

```

I got ` **ERROR** - 535 Authentication failed` otherwise - and in the last line of the rebuild console output you can see there’s an extra set of quotes in the command line. I think the env\_file variable declaration probably should also not have quotes around it, unlike my original post.)

thanks muchly for the help and have a wonderful day!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 25, 2025, 5:13pm UTC](https://meta.discourse.org/t/passing-email-api-key-to-container-without-hardcoding-in-app-yml/349002/4 "2025-02-25T17:13:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
