Where are Docker images stored on the host machine

2018-12-31 18:01发布

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?

19条回答
情到深处是孤独
2楼-- · 2018-12-31 18:37

On Debian Unstable/Sid,

docker info to find system-wide information.

images are stored at /var/lib/docker/image/overlay2/imagedb/content and

containers are stored at /var/lib/docker/containers

docker version 18.06.0-ce, API version 1.38

查看更多
几人难应
3楼-- · 2018-12-31 18:38

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.
查看更多
何处买醉
4楼-- · 2018-12-31 18:38

When using Docker for Mac Application, it appears that the containers are stored within the VM located at:

~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
查看更多
君临天下
5楼-- · 2018-12-31 18:38

In Docker for Windows, the logs are here: %USERPROFILE%\AppData\Local\Docker

查看更多
呛了眼睛熬了心
6楼-- · 2018-12-31 18:40

On Ubuntu you can "play" with images running

sudo baobab /var/lib/docker

Actually, images are stored within /var/lib/docker/aufs/diff

screenshot showing disk analyzer tool baobab running on /var/lib/docker

查看更多
一个人的天荒地老
7楼-- · 2018-12-31 18:40

check for the docker folder in /var/lib

the images are stored at below location:

/var/lib/docker/image/overlay2/imagedb/content
查看更多
登录 后发表回答