How To Change Docker Storage \ Data Folder On Windows Server 2016

In this blog post, I will show you how I change the storage location of Docker and Windows Containers on Windows Server 2016.

My Container Host Is running Docker Enterprise Edition version 17.06.2.ee.6 on Windows Server 2016.

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'

As you can see I created the file

Before, making any changes I must stop the Docker service using the following PowerShell command.

stop-service docker

Add Configuration

Now, that the Docker service Is stopped, I’ll add the code below that will change my storage location for docker.

In my case, I created a new folder on my C drive.

{
"data-root": "c:\\dockerdata"
}

After saving the configuration file, I’ll restart the docker service using the code below:

Restart-Service Docker

After the restart, docker will move the configuration files and new Images will be saved In the new location

Below, I’ll download a new Image

Docker pull microsoft/dotnet

And as you can see below, the content will be saved to the new location

This blog post was first published on our sister site https://www.deploycontainers.com


Posted

in

by