How to use variables for image names in docker-compose.yml

Hello, I have a rather strange problem that I don’t understand. First of all I work with version 2.4 of docker-compose and version 15.0.3 of balena-cli.

if in my docker-compose.yml I define image name like this :
image: project/app:qt-secure-entry-2f4f97e5

and I deploy with balena-cli:
balena deploy my_slug/my_fleet --registry-secrets ./registry-secrets.yml, it works

Now if I export the commit hash to a variable I export and use that variable in docker-compose.yml like this:

export TAG=2f4f97e5 //export variable
echo $TAG -->2f4f97e5 // show variable value

balena deploy my_slug/my_fleet --registry-secrets ./registry-secrets.yml

[Build] **qt-secure-entry** Preparing...

[Build] Built 1 service in 0 seconds

[Error] Deploy failed

(HTTP code 400) unexpected - invalid tag format

it doesn’t work.
Does balena-cli block variables in image names?
Why doing

image:project/app:qt-secure-entry-${TAG}
``` doesn't work ?

If ever someone has the same problem as me, the solution is to use envsubst. Here is an example:

    $ envsubst < docker-compose.yml.template > docker-compose.yml
    $ balena deploy my_slug/my_fleet --registry-secrets ./registry-secrets.yml
1 Like

I’m glad you found a solution and thanks for sharing it here!