I have several docker-compose.yml files that I want to use the same Dockerfile with, with a slight variation. So I want to pass an argument to that Dockerfile so that I can do something slightly different depending on whatever value the variable is set to.
What I have tried so far
docker-compose-A.yml file
version: '2'
services:
django:
build:
context: .
dockerfile: ./docker/Dockerfile
args:
- SOMETHING=foo
docker-compose-B.yml file
version: '2'
services:
django:
build:
context: .
dockerfile: ./docker/Dockerfile
args:
- SOMETHING=bar
I have a dockerfile I want to use SOMETHING in. e.g.
# Dockerfile
RUN echo $SOMETHING
That doesn't work. SOMETHING is not passed to the dockerfile.
Am I doing this incorrectly or is this not the intended usage?
Is there any other way to pass a variable to a Dockerfile from a docker-compose.yml file?
ARG SOMETHING
in Dockerfile?