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

Trouble with environment vars #379

Closed
koichirose opened this issue Dec 17, 2024 · 1 comment
Closed

Trouble with environment vars #379

koichirose opened this issue Dec 17, 2024 · 1 comment

Comments

@koichirose
Copy link

I'm having a weird issue, I set this in my docker-compose.yml:

...
environment:
      - TZ=${TZ}
      - BORG_PASSPHRASE=${BORG_PASSPHRASE}
      - BACKUP_CRON=${BACKUP_CRON}

and I have a .env file:

TZ=Europe/Berlin
BORG_PASSPHRASE="mypass"
VOLUME_SOURCE=/home/
BACKUP_CRON="20 */4 * * *"
...

If I run:

docker compose up -d
docker exec -it borgmatic bash

and then run env inside the container, I can see all my env vars just fine.

If I shut down the container and run:
docker compose run --rm borgmatic env
I can only see the following vars:

SHLVL=1
OLDPWD=/
PATH=/command:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/

But, if I run docker compose run --rm borgmatic borgmatic list
I can see this output:

...
Time Zone: Europe/Berlin
-----------------------------------
Applying custom cron
Cron job set as:
20 */4 * * * /usr/local/bin/borgmatic --stats -v 0 2>&1

crond: crond (busybox 1.37.0) started, log level 8
Enter passphrase for key ssh://myuser@myhost/./myrepo: 

So it's correctly getting the TZ and BACKUP_CRON vars, but not BORG_PASSPHRASE.

My end goal is to setup cron on the host and run backups with docker compose run instead of having the container always running with its own cron.

What's wrong with my setup?

@koichirose
Copy link
Author

Nevermind, just found this and fixed with S6_KEEP_ENV=1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant