'Retrieving a CI variable from Gitlab project and use it within Dockerfile

I have a CI variable that I would like to use within my docker file. I have tried to include it such as

ENV TESTING_UNIT=$TESTING_ID


Solution 1:[1]

It seems like that you need to specify to Dockerfile that it expects an argument variable

With the following approach it will be available in the container

Change:

ENV TESTING_UNIT=$TESTING_ID

To:

ARG TESTING_UNIT_ARG
ENV TESTING_UNIT=$TESTING_UNIT_ARG

and build the image:
docker build --build-arg TESTING_UNIT_ARG=$TESTING_ID

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1