Docker how to get volumes used by a container

前端 未结 1 1130
不知归路
不知归路 2021-02-12 14:04

I\'m using Docker version 1.10. How can I get the volumes used by a container?

I know I can get the containers by:

docker ps

And I can

相关标签:
1条回答
  • 2021-02-12 14:56

    You can get the detail volume information of a container by

    docker inspect --format="{{.Mounts}}" $containerID
    

    If I create a volume named "volumehello", and start a container named "hello" which use "volumehello":

    docker volume create --name volumehello
    docker run -it -d --name=hello -v volumehello:/tmp/data hello-world
    

    Then we can get the volume information of "hello" container by running:

    docker inspect --format="{{.Mounts}}" hello
    

    We will get:

    [{volumehello /var/lib/docker/volumes/volumehello/_data /tmp/data local z true rprivate}]
    
    • volumehello is the volume name
    • /var/lib/docker/volumes/volumehello/_data is the host location of the volume
    • /tmp/data is the mapped location of the volume within the container
    0 讨论(0)
提交回复
热议问题