A bit unclear. It creates a mount point using this name, but the actual file path does not use this name. If you run docker inspect {container-name} , you will see a type name: "Destination": "/mnt/something", and the actual location, for example: "Source": "/var/lib/docker/volumes/cb80c7802244dd3669eed8afb7d94b61366844d80677eb180fa12002db04ea7c/_data", .
This is because the Docker file is not bound to a specific host and cannot be sure that the host volume path will exist. You need to do this in the run statement (or equivalent). You can use api or docker inspect to find out where the volumes are after creating the container if you need to use this information in a script or similar.
Declaring a volume in a Dockerfile ensures that data is saved and available to the host โ even if no location is specified.
source share