Where are Docker images stored on the host machine?

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

提交回复
热议问题