title: Spring boot docker mount shared logback config files
body: <p>I have a spring boot application with a micro services architecture.  With something like 10 spring boot containers running.</p>
  
  <p>The setup for loading the logback.xml that I am aiming to do is looks something like this.
  <a href="https://i.stack.imgur.com/tqUTW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tqUTW.png" alt="logback-xml"></a></p>
  
  <p>How do I mount and load the logback.xml on a spring boot embedded jar / container  when I start the containers up.  </p>
  
  <p>My thoughts are something like this.</p>
  
  <p>This will run the spring boot app ok.</p>
  
  <pre><code>docker run -d --name=app1 app_image
  </code></pre>
  
  <p>Something like this is what I am looking to implement load the logback.xml</p>
  
  <pre><code>docker run -d --name=app1 --volume=/home/host-path/log-back-conig-dir/:/container-app-dir/ app_image
  
  docker run -d --name=app2 --volume=/home/host-path/log-back-conig-dir/:/container-app-dir/ app_image
  
  docker run -d --name=app3 --volume=/home/host-path/log-back-conig-dir:/container-app-dir/
  </code></pre>
  
  <blockquote>
    <p>Further info</p>
  </blockquote>
  
  <p>I am using the Dockerfile example taken from the official spring boot</p>
  
  <p><a href="https://spring.io/guides/gs/spring-boot-docker/" rel="nofollow noreferrer">spring.io/guides/gs/spring-boot-docker</a></p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM openjdk:8-jdk-alpine
  VOLUME /tmp
  ARG JAR_FILE
  ADD ${JAR_FILE} app.jar
  ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  </code></pre>
  
  <blockquote>
    <p>logback.xml looks like this</p>
  </blockquote>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
  
      &lt;springProperty scope="context" name="springAppName" source="spring.application.name"/&gt;
      &lt;include resource="org/springframework/boot/logging/logback/base.xml" /&gt;
  
      &lt;springProfile name="default,dev,staging"&gt;
          &lt;logger name="guru.springframework.controllers" level="DEBUG" additivity="false"&gt;
              &lt;appender-ref ref="CONSOLE" /&gt;
          &lt;/logger&gt;
      &lt;/springProfile&gt;
  
      &lt;springProfile name="dev"&gt;
          &lt;appender name="stash" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
              &lt;filter class="ch.qos.logback.classic.filter.ThresholdFilter"&gt;
                  &lt;level&gt;info&lt;/level&gt;
              &lt;/filter&gt;
              &lt;file&gt;/varlog/log-tracing-demo/build/logs/${springAppName}.log&lt;/file&gt;
              &lt;rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
                  &lt;fileNamePattern&gt;/var/log/log-tracing-demo/build/logs/${springAppName}.log.%d{yyyy-MM-dd}&lt;/fileNamePattern&gt;
                  &lt;maxHistory&gt;30&lt;/maxHistory&gt;
              &lt;/rollingPolicy&gt;
              &lt;encoder class="net.logstash.logback.encoder.LogstashEncoder" &gt;
                  &lt;includeContext&gt;false&lt;/includeContext&gt;
                  &lt;fieldNames&gt;
                      &lt;message&gt;msg&lt;/message&gt;
                  &lt;/fieldNames&gt;
                  &lt;customFields&gt;{"application_name":"${springAppName}"}&lt;/customFields&gt;
              &lt;/encoder&gt;
          &lt;/appender&gt;
          &lt;root level="info"&gt;
              &lt;appender-ref ref="CONSOLE" /&gt;
              &lt;appender-ref ref="stash" /&gt;
          &lt;/root&gt;
      &lt;/springProfile&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <blockquote>
    <p>Short version of question is..</p>
  </blockquote>
  
  <p>How do make multiple spring boot docker containers to mount and share the same single logback.xml file.  </p>