Reputation: 10134
I found this image: https://hub.docker.com/_/elasticsearch
And I want to inspect which paths are mountable as volumes. What I want is somehow to make a script that will input an image and will list which paths in it are mountable as volumes.
For example if I do (volumes-ls php
) I expect to get a value:
/var/www/html
Upvotes: 0
Views: 94
Reputation: 159750
You can't do this deterministically. There's no particular restrictions on which directories can be mounted as volumes.
The only thing you can find out is what directories will always have a volume mounted on them. If the Dockerfile contains a VOLUME
declaration then Docker will create an anonymous volume and mount it on that directory if nothing else has been mounted there. This is usually only done for data directories in stateful workloads; in your Elasticsearch example, the data directory, but not the configuration directory.
There are several other things it could make sense to mount. These include configuration directories and log output, it can be a way to inject static content into a server container like nginx
, and some use cases replace an image's entire code base with a bind mount. None of these cases use VOLUME
and there's no metadata in the image to specify what these directories could be. And so there's no way to figure this out programmatically; you'd have to figure it out from the image's human-readable documentation.
Upvotes: 1