Dockerfile instructions

Dockerfile VOLUME

Declares a mount destination. A new empty volume ordinarily receives existing image contents at that path. Name/source selection occurs at runtime. Not a backup or host-path binding. Record the anonymous volume identity before targeted removal; initial population is not synchronization.

Formal Syntax & Structure

docker syntaxdocker
VOLUME ["/path"]

Parameters & Attributes

NameTypeDescription
pathstringContainer mount destination.

Working Example

Example Snippetdocker
FROM busybox:1.37RUN mkdir /data && printf "seed\n" > /data/note.txtVOLUME ["/data"]CMD ["cat", "/data/note.txt"]
Docker Reference