1

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?

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.