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
?
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 metadataWhen 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
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 .
Actually, Docker images are stored in two files as shown by following command
$ docker info
Data file:
/var/lib/docker/devicemapper/devicemapper/data
Metadata file:
/var/lib/docker/devicemapper/devicemapper/metadata
The images are stored in /var/lib/docker/graph/<id>/layer
.
Note that images are just diffs from the parent image. The parent ID is stored with the image\'s metadata /var/lib/docker/graph/<id>/json
.
When you docker run
an image. AUFS will \'merge\' all layers into one usable file system.
On the newly released \'Docker for Windows\', which uses Hyper-V, data is located in the Docker virtual hard disk:
C:\\Users\\Public\\Documents\\Hyper-V\\Virtual hard disks\\MobyLinuxVM.vhdx
You can also open the \'Hyper-V Manager\' for access to the Docker / MobyLinuxVM.
For someone who is using Docker toolbox (that uses docker-machine), the answers concerning boot2docker on Mac OS X is not valid. The docker-machine VM is called \"default\" and it exists in the /Users/<username>/.docker/machine/machines/default/
directory.
On Ubuntu you can \"play\" with images running
sudo baobab /var/lib/docker
Actually, images are stored within /var/lib/docker/aufs/diff
In Docker for Windows (native Windows) the default container storage is at:
> docker info
...
Docker Root Dir: C:\\ProgramData\\Docker
...
If you are using Docker for MAC (not boot2docker
) then the location is /Users/<</>UserName></>/Library/Containers/com.docker.docker/Data/
As answered here, if you\'re on Mac, it is located at
/Users/MyUserName/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
Expanding on Tristan\'s answer, in Windows with Hyper-V you can move the image with these steps from matthuisman:
In Windows 10,
- Stop docker etc
- Type \"Hyper-V Manager\" in task-bar search box and run it.
- Select your PC in the left hand pane (Mine is called DESKTOP-CBP**)
- Right click on the correct virtual machine (Mine is called MobyLinuxVM)
- Select \"Turn off\" (If it is running)
- Right click on it again and select \"Move\"
- Follow the prompts
I use the boot2docker for Docker on Mac OSX, so the images is stored into the /Users/<USERNAME>/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vmdk
.
In Docker for Windows, the logs are here: %USERPROFILE%\\AppData\\Local\\Docker
If you keep in mind that Docker is still running in a VM, the system paths are relative to the VM and not from the Mac Osx system. As it says all is contained in a VM file :
/Users/MyUserName/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
Try to run Alpine image with this volume option and the ls command you are able to list the VM host:
docker run --rm -it -v /:/vm-root alpine:edge ls -l /vm-root
After this just try :
docker run --rm -it -v /:/vm-root alpine:edge ls -l /vm-root/var/lib/docker
Now, you are able to list the docker folder from the WM host
I can answer this question only for Ubuntu users:
The root directory of docker can be found when you run the command docker info
Docker directory will be given in this line: \"Docker Root Dir: /var/lib/docker
\"
About the docker images, they are stored inside the docker directory:
/var/lib/docker/aufs/diff/
Remember these things are not same in all version of docker. Currently, I am using 1.12.3.
check for the docker folder in /var/lib
the images are stored at below location:
/var/lib/docker/image/overlay2/imagedb/content
On Fedora, Docker uses LVM for storage if available. On my system docker info
shows:
Storage Driver: devicemapper
Pool Name: vg01-docker--pool
Pool Blocksize: 524.3 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file:
Metadata file:
Data Space Used: 9.622 GB
...
In that case, to increase storage, you will have to use LVM command line tools or compatible partition managers like blivet.
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