Use Environment variables from the running container
With the command parameter, is there a way I can access an enviroment variable that is already inside the container?
For example I'm using mazzolino/restic It defines a number of environment variables for restic that include some backup args - eg $RESTIC_BACKUP_ARGS - as these are already defined, and in the container, and useful, I was hoping if I run a command in this container I can access this variable.
I've tried:
deck-chores.daily-job.command: bash -c "restic backup /data/Documents $RESTIC_BACKUP_ARGS $RESTIC_FORGET_ARGS &> /proc/1/fd/1"
deck-chores.daily-job.cron: "* * * 7 32 * "
and
deck-chores.daily-job.command: bash -c "restic backup /data/Documents ${RESTIC_BACKUP_ARGS} ${RESTIC_FORGET_ARGS} &> /proc/1/fd/1"
deck-chores.daily-job.cron: "* * * 7 32 * "
to no effect. Any way I can access these variablres?
i guess that bash isn't passing the environment variables to the command. if you figure out that this is the case and how it can be tackled, i'd be interested in a note for the docs.
another way is to place/mount an executable script in the container filesystem and call that directly.
I think I did work it out.
deck-chores.job-documents.command: bash -c "restic backup /data/Documents --tag Documents --verbose $$RESTIC_BACKUP_ARGS --exclude-file=/config/exclude.file &> /proc/1/fd/1
I’ll try to confirm that again, as I didn’t end up using it.
running it a restic docker container, that knows about the repository and password already.
could you come to a final conclusion?
Sorry for the delay. Yes the command above the variable $$RESTIC_BACKUP_ARGS is resvolved.
I tested it with an echo command of the same variable and I can see them being output.
deck-chores.job-pictures-test.command: bash -c "echo $$RESTIC_BACKUP_ARGS &> /proc/1/fd/1"
and the log output from the container:
--tag ChangingData --tag CameraVideos --tag eBooks --tag OldCameraVideos --tag Music --tag Documents --tag Pictures --exclude-file=/config/exclude.file --exclude='*.tmp' --verbose