Alex Flint
Alex Flint

Reputation: 6736

programmatic access to docker volumes from host

I am using the docker HTTP API described here.

Suppose I get a volume ID using the GET /volumes API endpoint. Is it possible for me to inspect the contents of this volume (list files, read files)?

I understand that I could create a container that mounts this volume and then use the /containers/(id)/archive endpoint to download files from it, but this seems like a rather expensive operation when all I wish to do is inspect the contents of a single file on the volume.

Upvotes: 2

Views: 239

Answers (1)

Alexis Tacnet
Alexis Tacnet

Reputation: 535

I think the right thing is too execute the scripts you want to execute in a container with the volumes mounted, but you can just list the files and folders in the volume folder here : /var/lib/docker/volumes/.

This path is gonna change if you tweak a bit docker, but your volumes are always stored somewhere, just go inside the folder corresponding at your volume ID.

See ya !

Upvotes: 1

Related Questions