Docker-compose unable to read environment variable

I’m attempting to run a docker-compose.yml file in this project, which contains some environment variable interpolation (interpolation docs). For whatever reason its not picking up the var.

There’s a related bug (now closed) in docker-compose. I’ve tried versions 2.20.2 (unstable) and 2.18.1 (23.05) of docker-compose, both are from after the fix for that bug.

What happens:

[bburdette@HOSS:~/op-code/VideoDeduplication]$ echo $BENETECH_DATA_LOCATION
/home/bburdette/thegoods/VideoDeduplication_Files

[bburdette@HOSS:~/op-code/VideoDeduplication]$ docker-compose up -d
parsing /home/bburdette/op-code/VideoDeduplication/docker-compose.yml: invalid interpolation format for services.dedup-app.volumes.[].
You may need to escape any $ with another $.
${BENETECH_DATA_LOCATION:?

Please set "BENETECH_DATA_LOCATION" environment variable to the root folder of your video files.}:/project/data

Q: Is there some perhaps some nixos specific bash behavior that might cause this problem?

got around it by just hardcoding the dirname. still curious why this doesn’t work, if anyone has any ideas.

Please check if the variable was actually set in the environment!

printenv BENETECH_DATA_LOCATION

Yep its there

[bburdette@HOSS:~/op-code/VideoDeduplication]$ printenv BENETECH_DATA_LOCATION
/home/bburdette/thegoods/VideoDeduplication_Files

I can start building the compose after applying the following patch:

git diff -U1
diff --git a/docker-compose.yml b/docker-compose.yml
index 40fbb133..77c41e10 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -51,3 +51,3 @@ services:
       # on your host machine where you placed the source data
-      - "${BENETECH_DATA_LOCATION:?\n\nPlease set \"BENETECH_DATA_LOCATION\" environment variable to the root folder of your video files.}:/project/data"
+      - "${BENETECH_DATA_LOCATION:?Please set \"BENETECH_DATA_LOCATION\" environment variable to the root folder of your video files.}:/project/data"
       # You can specify BENETECH_FILE_STORAGE_DIRECTORY environment variable to
@@ -95,3 +95,3 @@ services:
       # on your host machine where you placed the source data
-      - "${BENETECH_DATA_LOCATION:?\n\nPlease set \"BENETECH_DATA_LOCATION\" environment variable to the root folder of your video files.}:/project/data"
+      - "${BENETECH_DATA_LOCATION:?Please set \"BENETECH_DATA_LOCATION\" environment variable to the root folder of your video files.}:/project/data"
       # You may want to set BENETECH_TASK_LOGS environment variable to
@@ -132,3 +132,3 @@ services:
       # on your host machine where you placed your video files
-      - "${BENETECH_DATA_LOCATION:?\n\nPlease set \"BENETECH_DATA_LOCATION\" environment variable to the root folder of your video files.}:/project/data"
+      - "${BENETECH_DATA_LOCATION:?Please set \"BENETECH_DATA_LOCATION\" environment variable to the root folder of your video files.}:/project/data"
       # You may want to set BENETECH_TASK_LOGS environment variable to

I canceled the build though:

$ BENETECH_DATA_LOCATION=$(pwd) docker compose build
WARN[0000] The "BENETECH_MODE" variable is not set. Defaulting to a blank string. 
WARN[0000] The "BENETECH_MODE" variable is not set. Defaulting to a blank string. 
WARN[0000] The "BENETECH_MODE" variable is not set. Defaulting to a blank string. 
[+] Building 6.4s (3/3) FINISHED                                                                                                                                                                                                                                              
 => CANCELED [dedup-app internal] booting buildkit                                                                                                                                                                                                                       6.4s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                                                                                       6.4s
 => CANCELED [server internal] booting buildkit                                                                                                                                                                                                                          6.4s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                                                                                       6.4s
 => CANCELED [celery-worker internal] booting buildkit                                                                                                                                                                                                                   6.4s
 => => pulling image moby/buildkit:buildx-stable-1                                                                                                                                                                                                                       6.4s
canceled
1 Like

Nice! Thx for tracking that down!