Having the following docker-compose file:
db: build: . environment: - MYSQL_ROOT_PASSWORD=password - ENV=test env_file: .env
It works ok this way:
docker-compose.yml
version: '3.5' services: container: build: context: . args: ENV: ${ENV} # from .env file env_file: - .env
Dockerfile
# from compose args ARG ENV ADD ${ENV}/data.xml /data/
.env
ENV=myenv
Thus all the values are taken from .env file