Docker Swarm with image versions externalized to .env file

Olivier picture Olivier · Jun 22, 2017 · Viewed 7.8k times · Source

I used to externalized my image versions to my .env file. This make it easy to maintain and I don't modify my docker-compose.yml file just to upgrade a version, so I'm sure I won't delete a line by mistake or whatever.

But when I try to deploy my services with stack to the swarm, docker engine complains that my image is not a correct reposity/tag, with the exact following message :

Error response from daemon: rpc error: code = 3 desc = ContainerSpec: "GROUP/IMAGE:" is not a valid repository/tag

To fix this, I can fix the image version directly in the docker-compose.yml file. Is there any logic here or it that a bug? But this mixes fix part of the docker-compose and variable ones.

Cheers, Olivier

Answer

BMitch picture BMitch · Jun 22, 2017

The yaml parser in docker stack deploy doesn't have all the same features of that in docker-compose. However, you can use docker-compose config to output a yaml file after it's done all the variable substitutions, extending other files, and merging multiple files together. This effectively turns docker-compose into a preprocessor.