microsoft/Windows-Containers

How do we change the install location to another drive?

beckerben opened this issue · 7 comments

We are trying to figure out how to install to the "d:" drive rather than the "c:\ProgramData\Docker" and can't figure out how to do this. We tried specifying the DockerPath and DockerDPath parameters but ran into issues with that.

Hey @beckerben, have you tried using --installation-dir=<path>? This changes the default installation location (C:\Program Files\Docker\Docker).

Source: https://docs.docker.com/desktop/install/windows-install/#install-docker-desktop-on-windows

We're installing on a windows server and can't use the docker desktop so are using the install-docker-ce.ps1 script provided in this repo. It doesn't seem to allow us to change the default installation path. We tried hacking it without success.

I see. @brasmith-ms @Howard-Haiyang-Hao is there any limitations to setting DockerPath and DockerDPath to "d:" drive?

I'm interested in the same feature. Actually giving "D:" for DockerPath and DockerDPath moves the executables in D: drives, but the Images are stored in C:\ProgramData\docker

grafik

Hello, it sounds like you would like to switch your "data-root" to a directory on the D: drive. This can be done adding a configuration file for Docker. Here is a doc that shows how to change the data-root among other configurations. The sample json in the example specifies the alternate path for the data (such as images and containers) to be stored:

{   
"data-root": "d:\docker"
}

Please note that Docker service needs to be restarted after adding/modifying Docker configurations.

A simple powershell function to do this operation may look like this:

function SetupDocker()
{
        $daemonPath = Join-Path $Env:ProgramData "Docker\config\daemon.json"

        if (Test-Path $daemonPath)
        {
            Write-Host "Daemon file exists. Skipping docker set up..."
        }
        else
        {
            Write-Host "Changing docker configurations..."
            Set-Content -Path $daemonPath -Value '{ "data-root": "D:\\docker" }'
            Restart-Service Docker
        }
}

@beckerben I was able to get the docker data folder created on a different drive. Here are the steps that I took:

  1. dockerd --unregister-service
  2. dockerd --register-service --run-service --data-root e:\docker
  3. net start docker
image

Please let me know if this is anything else that I can help with.

To install the docker to a different location, here are the steps:

  1. Download the docker installer:
    image

  2. "Docker Desktop Installer.exe" install --accept-license --backend=windows --always-run-service --windows-containers-default-data-root=d:\dockerdata --installation-dir=d:\docker

If you reboot your host, the docker service many stop working again. Here is a workaround that I did:

image