How to create a volume from a local path in a Dockerfile?

With command line arguments, I can indicate that I want to mount a local directory as a volume:

docker run -i -t -v /path/to/directory/:/mount/point testimage

However, I can’t find anything to describe the syntax to VOLUME in a Dockerfile to do the same thing. Can anyone explain what this looks like?

  • Trouble communicating between docker containers
  • How can I know which docker will restart after docker daemon restarts
  • What are the advantages of docker containers over statically linked EXEs?
  • Deploy mongodb replicaset servers with Docker on different physical servers
  • How to configure Let's encrypt certificates for nginx inside a docker image?
  • Simple script needed to delete all docker images older than 4 weeks
  • Is it possible to run multiple docker/lxc/lxd container based on one base container?
  • how to use pip to install pkg from requirement file without reinstall
  • Maven run docker image with java ee application
  • Faster deploy of a docker image?
  • Running commands for docker container
  • Unable to connect to Elasticsearch in ELK Docker container
  • One Solution collect form web for “How to create a volume from a local path in a Dockerfile?”

    Dockerfiles only define the right side (which paths within the container are volumes) — not the local/left side.

    The mapping is done during container creation, not image creation.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.