title: docker-compose override application properties
body: <p>Having a Spring Boot application we are using application.yml file to store properties. I got a task to give a user a possibility to override some properties while starting an application. Taking into consideration we have dockerised our app docker-compose file is the very right place I believe for that. I found one option which works actually, env_file:</p>
  
  <pre><code>backend:
      build:
        context: backend
        dockerfile: Dockerfile.backend
      restart: always
      ports:
        - 3000:3000
      env_file:
        - backend/custom.env
      volumes:
        - ../m2_repo:/root/.m2/
        - ../{APP_NAME}/data_sources:/backend/data_sources/
      links:
        - database
      networks:
        main:
          aliases:
            - backend
  </code></pre>
  
  <p>This solves perfectly my task and all the KEY=VALUE pairs override existing in application.yml properties. However, I have 2 questions:</p>
  
  <ol>
  <li><p>It appeared that having multiple services in my docker-compose file I need specify a separate env_file for each service, which is probably not very convenient. Is there a possibility to have one common env_file for the whole docker-compose file?</p></li>
  <li><p>I know that for docker-compose run command there is an option -e where i can put key=value pairs of env variables. Is there any similar option for docker-compose up? I mean in order not to use env_file at all.</p></li>
  </ol>