Where are Docker images stored on the host machine?

后端 未结 29 1702
逝去的感伤
逝去的感伤 2020-11-22 06:28

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

相关标签:
29条回答
  • 2020-11-22 06:45

    In Docker for Windows (native Windows) the default container storage is at:

       > docker info
       ...
       Docker Root Dir: C:\ProgramData\Docker
       ...
    
    0 讨论(0)
  • 2020-11-22 06:47

    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.

    0 讨论(0)
  • 2020-11-22 06:47

    Use docker info command to display system-wide information and the location may vary.

    Depending on the storage driver in use, additional information can be shown, such as pool name, data file, metadata file, data space used, total data space, metadata space used, and total metadata space.

    The data file is where the images are stored and the metadata file is where the meta data regarding those images are stored. When run for the first time Docker allocates a certain amount of data space and meta data space from the space available on the volume where /var/lib/docker is mounted.

    Here is the example on Ubuntu (check Root Dir):

    $ docker info
    ...
    Server Version: 18.06.1-ce
    Storage Driver: aufs
     Root Dir: /var/snap/docker/common/var-lib-docker/aufs
    ...
    Docker Root Dir: /var/snap/docker/common/var-lib-docker
    ...
    

    And here is the example on Travis CI (see Docker Root Dir):

    $ docker info
    Server Version: 17.09.0-ce
    Storage Driver: overlay2
     Backing Filesystem: extfs
    ...
    Docker Root Dir: /var/lib/docker
    ...
    

    You can use --format parameter to extract that information into a single file, e.g.

    $ docker info --format '{{.DriverStatus}}'
    [[Root Dir /var/snap/docker/common/var-lib-docker/aufs] [Backing Filesystem extfs] [Dirs 265] [Dirperm1 Supported true]]
    

    or:

    $ docker info --format '{{json .DriverStatus}}'
    [["Root Dir","/var/snap/docker/common/var-lib-docker/aufs"],["Backing Filesystem","extfs"],["Dirs","265"],["Dirperm1 Supported","true"]]
    
    0 讨论(0)
  • 2020-11-22 06:47

    use docker inspect container_id
    find folder under MergedDir

    # example. 
    "MergedDir": "/var/lib/docker/overlay2/f40cc2ea8912ec3b32deeef5a1542a132f6e918acb/merged 
    
    0 讨论(0)
  • 2020-11-22 06:47

    In Windows 2016, docker (DockerMsftProvider) uses the folder "windowsfilter" under docker root

    >docker info
    ...
    Storage Driver: windowsfilter
    ...
    Docker Root Dir: C:\ProgramData\docker
    ...
    

    It uses the "tmp" folder under docker root to download the files and it deletes the files after extracting the downloaded files to "windowsfilter" folder.

    0 讨论(0)
  • 2020-11-22 06:49

    this was the old way of doing, now it has changed. Disregard this answer as of 2019

    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 .
    
    0 讨论(0)
提交回复
热议问题