Question about VOLUME section in Dockerfile

hi there. i’m new to docker.

how do i configure multiple volumes to share my host’s directories in Dockerfile?

VOLUME ["/data":"/data1", “/etc/test”:"/data2", “/etc/a”:"/data3"] or

VOLUME ["/data:/data1", “/etc/test:/data2”, “/etc/a:/data3”]

i tried few things but it doesn’t work. it only works when use -v option in run-time.

if this is possible thing, it can link volumes automatically when use run, “without -v options”.

if this is “not” possible thing, why use VOLUME in Dockerfile? is it for just specification for those who pull created-image from other?

i just wondering whether it is possible thing or not. thanks!

It is not possible to force a host bind mount without specifying it during run. Having that in the Dockerfile is for other containers to bind to that volume using –volumes-from.