Where are Docker images stored on the host machine?

后端 未结 29 1704
逝去的感伤
逝去的感伤 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:55

    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
    

    UPDATE (Courtesy of mmorin):

    As of Jan 15 2019 it seems there is only this file:

    ~/Library/Containers/com.docker.docker/Data/vms/0/Docker.raw
    

    that contains the Docker Disk and all the images and containers within it.

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

    For "Docker Desktop", click on docker system tray icon and click "Settings".

    On the Advanced tab, you can see the disk image location.

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

    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
    
    0 讨论(0)
  • 2020-11-22 07:00

    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

    0 讨论(0)
  • 2020-11-22 07:02

    Environment: Windows 10 Pro, docker desktop 2.0.3.0 edge

    right-click docker icon in system tray, select settings - advanced :

    Disk image location (editable via the browser) :

    C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\DockerDesktop.vhdx

    (it's there - Documents directory is hidden)

    0 讨论(0)
  • 2020-11-22 07:02

    If anyone need it for scripting purposes, here is a one-line solution.

    In POSIX shell, with PCRE enabled grep, try:

    DOCKER_ROOT_DIR="$(docker info 2>&1 | grep -oP '(?<=^Docker Root Dir: ).*')"

    In PowerShell:

    $DOCKER_ROOT_DIR="$(docker info 2>&1 | foreach {if($_ -match "Docker Root Dir"){$_.TrimStart("Docker Root Dir: ")}})"

    Note, when on Windows 10 (as of 10.0.18999.1), in default configurations, it returns:

    • C:\ProgramData\Docker in "Windows containers" mode
    • /var/lib/docker, in "Linux containers" mode
    0 讨论(0)
提交回复
热议问题