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?

  • Can't delete Docker Image from Registry
  • Docker swarm: guarantee high availability after restart
  • Using env vars in a docker cmd?
  • Concourse CI: leverage docker image cache
  • Do not download all Maven dependencies on a Docker build
  • Should you recreate containers when deploying web app?
  • Docker 'data only container' being shut down
  • Increase HeapSize in Tomcat for all my applications
  • /bin/sh: 1: apk: not found while creating docker image
  • docker on mac: unable to resolve path to a file on mac from the program running in container
  • How docker volume container (mounted a host directory ) used in compose file version 2
  • How to get the container Id of the running container using docker-java?
  • 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.