Reputation: 24875
If I start a container from an image, the Dockerfile of which has an entry like this:
VOLUME ["/data"]
with what subcommand of docker run
should I start a container, so that when I list the volumes via docker volume ls
, I see the name I gave to the volume and not some long random hash?
Upvotes: 0
Views: 154
Reputation: 158676
If you use the ordinary docker run -v
option to mount something on that same path, Docker won't create an anonymous volume there.
docker volume create something
docker run -v something:/data ...
In fact, you don't need a Dockerfile VOLUME directive to do this: you can mount a volume or host directory on to any container path regardless of whether or not it's declared as a VOLUME directory. There's not a lot of benefits to having that in the Dockerfile, and it has some confusing side effects; I'd suggest just deleting that line.
Upvotes: 2