I have a docker-compose.yml
file and in the terminal I am typing docker-compose up [something]
but I would also like to pass an argument to docker-compose.yml
. Is this possible? I've read about interpolation variables and tried to specify a variable in the .yml
file using ${testval}
and then docker-compose up [something] var="test"
but I receive the following error:
WARNING: The testval variable is not set. Defaulting to a blank string.
ERROR: No such service:testval=test
You need to ensure 2 things:
docker-compose.yml
has the environment variable declared. For example,docker-compose up
is called:Note that this is not equivalent to pass them during build, as it is not advisable to store secrets in docker images.