Answers: <p>You do not specify a volume source when you define a volume in an image. Doing so would be a potential security exploit where an image could mount a private volume with a common name and send the contents of that volume over the network. To create your volumes with known names, and have that defined in a file, you would do that at runtime with a docker-compose.yml file when the container is created. E.g.</p>
  
  <pre><code>version: '3'
  volumes:
    - app_data
  services:
    app:
      image: your_image:1.0
      volumes:
        - app_data:/data
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-12-18T12:33:38.073Z
Answers: 2018-12-18T12:33:38.073Z
Answers: BMitch
Body: <p>In Dockerfile we can use <code>VOLUME /some/folder</code> to let docker always create a volume for the specified folder when calling <code>docker run</code>, without having to explicitly use the <code>-v</code> parameter. The volume created will have a random (unreadable) alphanumerical name.</p>
  
  <p><strong>Question:</strong> is it possible to specify a readable name for the volume on container creation?</p>
  
Tags: <docker><dockerfile>
Title: Giving a meaningful name to Dockerfile's VOLUME
UserDisplayName: ivicaa
ThreadText: # Giving a meaningful name to Dockerfile's VOLUME
  
  (Asked by: username_0 on 2018-12-17)
  
  In Dockerfile we can use `VOLUME /some/folder` to let docker always create a volume for the specified folder when calling `docker run`, without having to explicitly use the `-v` parameter. The volume created will have a random (unreadable) alphanumerical name.
  
  **Question:** is it possible to specify a readable name for the volume on container creation?
  
  **Tags:** docker, dockerfile
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-18. Score: 2 | Accepted answer
  
  You do not specify a volume source when you define a volume in an image. Doing so would be a potential security exploit where an image could mount a private volume with a common name and send the contents of that volume over the network. To create your volumes with known names, and have that defined in a file, you would do that at runtime with a docker-compose.yml file when the container is created. E.g.
  
  ```
  version: '3'
  volumes:
    - app_data
  services:
    app:
      image: your_image:1.0
      volumes:
        - app_data:/data
  
  ```
  
  
  ---
  
  