0

I'm using docker to build and deploy applications. After building the image i need to tag and use that image from another system which has docker-compose on it. I'm using Jenkins to build and deploy images to private docker registries. Docker compose file on the host system should automatically pull those images based on tag version.

How to pass variables to docker-compose to substitute tag values ?

Example: if a=2.4 then it should substitute 2.4 inside docker-compose file for a.

version: '2'
services:
 web:
  image: httpd:$a
  ports:
    - 80:80

1 Answer 1

2

You can actually use this as written. Docker compose will use your OS environment to populate variables using the syntax that you have here.

On Mac/Linux:

export a=2.4
docker-compose up
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks and when i export variables from jenkins machine to client machine , i couldn't read the variable from the shell inside client machine. I'm getting following error: WARNING: The a variable is not set. Defaulting to a blank string
I have added in a .bashrc and everything works as expected. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.