ScanSkill

VOLUME

The VOLUME instruction creates a mount point with the specified name and mounted volumes from the native host or other containers.

Syntax

VOLUME ["/data"]‘

Note: The value can be a JSON array, VOLUME ["/var/log/"], or a plain string with multiple arguments such as VOLUME /var/log or VOLUME /var/log /var/db.

Example

FROM ubuntu
RUN mkdir /test
RUN echo "This is just a test text." > /test/example
VOLUME /test

Here, this Dockerfile creates an image that causes docker run to create a new mount point at /test and copy example file into the newly created volume.