I have several docker-compose.yml files with which I want to use the same Dockerfile, with a little change. So I want to pass an argument to this Dockerfile so that I can do something a little different depending on what variable value is set.
What have i tried so far
file docker-compose-A.yml
version: '2' services: django: build: context: . dockerfile: ./docker/Dockerfile args: - SOMETHING=foo
file docker-compose-B.yml
version: '2' services: django: build: context: . dockerfile: ./docker/Dockerfile args: - SOMETHING=bar
I have a docker file in which I want to use something. for instance
# Dockerfile RUN echo $SOMETHING
This does not work. SOMETHING is not transferred to the Docker file.
Am I doing it wrong or is this not intended use?
Is there any other way to pass the variable to the Dockerfile from the docker-compose.yml file?
source share