title: Spring Boot & Docker using VOLUME /tmp
body: <p>Is anyone able to explain why the <a href="https://spring.io/guides/gs/spring-boot-docker/#_containerize_it" rel="noreferrer">Spring Boot Docker Guide</a> recommends adding the <code>/tmp</code> volume as follows:</p>
  
  <p><code>VOLUME /tmp
  </code></p>
  
  <p>It explains:</p>
  
  <blockquote>
    <p>We added a VOLUME pointing to "/tmp" because that is where a Spring Boot application creates working directories for Tomcat by default. The effect is to create a temporary file on your host under "/var/lib/docker" and link it to the container under "/tmp". </p>
  </blockquote>
  
  <p>however, I'm not really clear why you'd want/need to do this. </p>
  
  <p>If the java application creates any files in the /tmp directory of the container I don't see what the need is to configure this as a volume since, as far as I understand, it would result in files bypassing the union filesystem and being written persistently in the Docker host to <code>/var/lib/docker</code>. Could this also result in the "temporary" files created in the container not being automatically deleted when the container is stopped?</p>
  
  <p>My spring boot app (which does create temporary files) seems to run ok without this <code>VOLUME</code>, but I wonder if there are any negative consequences to not following this advice.</p>
  
  <p>Thanks.</p>