How to dynamically change the docker-compose image field How to dynamically change the docker-compose image field docker docker

How to dynamically change the docker-compose image field


In the docker-compose file, you can have variables susbsitution based on environment variables. This is documented under Variable Substitution.

You can use the following to specify a different version for the image:

image: smstake:${SMSTAKE_VERSION}

And inside the jenkins job that deploys, you can just set this environment variable and run the docker stack command:

SMSTAKE_VERSION=v1.2.0 docker stack deploy -c docker-compose.yml stackname