Using environment variable in the base docker image




I’m using CircleCI in most of my project to build a docker images, and I use my own custom (public) image as base image. I often make changes to it, and i understand that all reference to it in my other projects must use a tag (no mutable tag). Also this is annoying I understand the reason. To work around that fact I would like to use a PROJECT environment variable (here OWN_BASE_IMAGE_GO_1_8) to reference the base image to use.
That environment variable is set like so OWN_BASE_IMAGE_GO_1_8=myimage:1.2.3 in my project.

So my config.yam is like so:
version: 2
working_directory: /go/src/
- image: (eval echo {OWN_BASE_IMAGE_GO_1_8})

steps: ...

That’s not working. Is there anything I can do to make this possible?
The motivation is to not to have to update all my other project’s config.yml everytime my base image gets updated (changing its tag). I know how to work around the limitation of not having (yet) global environment variables, so i have a script that uses your API to set that environment variable in my projects.

If it can’t work at the moment, will (or can) it be addressed in a newer version/release?

Thank you / Matt


Would the machine executor help at all?

It’d let you always pull :latest manually without relying on a cache.


I might be able to use the machine type but it would require a lot of changes in my config.yml steps if i can’t have the primary docker image mounting like in the docker executor.

Is there any chance @rohara that the docker image name will be able to take any environment variable some time soon?

Thank you


The thing with using - image: $(eval echo ${OWN_BASE_IMAGE_GO_1_8}) is I don’t know where you would evaluate that env var.


You mean that you don’t know in which context that expression would be evaluated? The environment variable itself is in the CircleCI project. You don’t have any preprocessor task of the config.yml that could operate that evaluation?



That’s not really what an environment variable is. It’d be cool if this worked, defining an image with a variable name, but it would not work with 2.0.


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.