Where are Docker images stored on the host machine?

I managed to find the containers under directory /var/lib/docker/containers , but I can't find the images.

What are the directories and files under /var/lib/docker ?


The contents of the /var/lib/docker directory vary depending on the driver Docker is using for storage.

By default this will be aufs but can fall back to overlay , overlay2 , btrfs , devicemapper or zfs depending on your kernel support. In most places this will be aufs but the RedHats went with devicemapper .

You can manually set the storage driver with the -s or --storage-driver= option to the Docker daemon.

  • /var/lib/docker/{driver-name} will contain the driver specific storage for contents of the images.
  • /var/lib/docker/graph/<id> now only contains metadata about the image, in the json and layersize files.
  • In the case of aufs :

  • /var/lib/docker/aufs/diff/<id> has the file contents of the images.
  • /var/lib/docker/repositories-aufs is a JSON file containing local image information. This can be viewed with the command docker images .
  • In the case of devicemapper :

  • /var/lib/docker/devicemapper/devicemapper/data stores the images
  • /var/lib/docker/devicemapper/devicemapper/metadata the metadata
  • Note these files are thin provisioned "sparse" files so aren't as big as they seem.

  • 当使用Docker for Mac应用程序时,看起来这些容器存储在位于以下位置的虚拟机中:

    ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
    

    In the special case of Mac OS X or Windows, using boot2docker, your Docker images are stored within a VirtualBox VM managed by boot2docker.

    This VM will be stored in normal place of VirtualBox images:

    OS X: ~/VirtualBox VMs/boot2docker-vm

    Windows: %USERPROFILE%/VirtualBox VMs/boot2docker-vm

    You can reset it by running (WARNING: This will destroy all images you've built and downloaded so far):

    boot2docker down
    boot2docker destroy
    boot2docker init
    boot2docker up
    

    This is especially useful if you kept tons of intermediate images when building / debugging a build without the useful --rm options, I quote them here for reference: Use:

    docker build -t webapp --rm=true --force-rm=true .
    

    instead of:

    docker build -t webapp .
    
    链接地址: http://www.djcxy.com/p/18266.html

    上一篇: Docker如何更改存储库名称或重命名映像?

    下一篇: Docker镜像存储在主机上的位置是什么?