Answer the question
In order to leave comments, you need to log in
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
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.
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 questionAsk a Question
731 491 924 answers to any question