Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, 19 June 2021

Change docker images and containers location with Windows 10


Docker with windows has 2 mode windows and linux (wsl)

  1. For Windows Mode:

    Docker Configuration File:

    By default, Docker stores Images and other configuration files In the location below:

    C:\ProgramData\Docker

    Which also mean that Images, volumes, etc will be stored in the same location.

    To change the storage location with the need to create a configuration file called Daemon.json and specify the new location.

    By default, the file doesn’t exist and we need to create under the path below:

    'C:\ProgramData\Docker\config\daemon.json'

    set data-root path

    {
    "data-root": "D:\\ProgramData\\Docker"
    }

    for old docker use graph instead of data-root

    You must stop docker service before changing daemon.js and start again after changing.

    you can also do that from GUI docker settings --> Docker Engine

  2.  For linux subsystem (wsl) mode:
    Before applying the below steps check installing Windows Subsystem for Linux (WSL).
    • Quit docker
    • Run from command prompt:
              wsl --list -v
              you will see


    • Export docker-desktop-data into a file
      wsl --export docker-desktop-data "E:\Code\DevOps\Docker\docker-desktop-data.tar"


    • Unregister docker-desktop-data from wsl
      wsl --unregister docker-desktop-data
    • Import the docker-desktop-data back to wsl but with new path
      wsl --import docker-desktop-data "E:\Code\DevOps\Docker\wsl\data" "E:\Code\DevOps\Docker\docker-desktop-data.tar" --version 2 
    • Start the Docker Desktop again and it should work

Change docker images and containers location with Windows 10

Docker with windows has 2 mode windows and linux (wsl) For Windows Mode: Docker Configuration File: By default, Docker stores Images and ot...