I can specify an arg in docker-compose.yml as follows (e.g. RAILS_ENV)
version: '3'
services:
web:
build:
context: .
args:
RAILS_ENV: production
The Dockerfile uses this ARG and sets anENV so that my image gets built with that environment variable:
FROM ruby:2.5.1
# ...
ARG RAILS_ENV
ENV RAILS_ENV=$RAILS_ENV
# ...
# Image contains environment variable `$RAILS_ENV` as `"production"`
However, what if I want to use something other than the hard-coded value of "production" ?
Is there a way to pass the variable into the
docker-compose.ymlfile dynamically?Additionally, can I specify a default value (e.g.
development) indocker-compose.ymlin case I don't pass in anything?
Thanks!