Y
Y
Yourmind2019-09-09 12:01:49
Java
Yourmind, 2019-09-09 12:01:49

Why add VOLUME /tmp to the dockerfile?

I don't really understand the VOLUME /tmp line in the dockerfile? More precisely, in principle, the VOLUME command. Can you explain why it is needed in simple terms? And also in a specific example: I am creating a spring boot application and judging by what I found on his official website, he suggests writing the following docker file:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
chupasaurus, 2019-09-09
@chupasaurus

The VOLUME command is needed so that mutable data that appears during lifetime is stored on the host separately from the container file system, can be processed / reused after its removal and administered via the Docker API.

D
Dmitry, 2019-09-09
@q2digger

Look, it's actually a crutch.
When building a container, this directive tells us to create a mount point. And there may be (during the assembly) some data, logs or anything else.
Further, when you start this container, the specified volume with the same data will be automatically created.
An example that illustrates this is in the official manual.
https://docs.docker.com/engine/reference/builder/#...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question