1

I try to run the following script but dockerd is not recognized in my workstation.

My OS is windows 10. Just installed the latest version of docker that is 18.09.2

It is my first time with docker.

2

Find other way to do it based on this post.

For Unix containers, the path for images can be changed by Docker Desktop interface, at settings form. But if you use the windows containers feature then a second service is installed, the "Docker Engine". To change the image folder for this service do the following steps:

1) Get the path to the config file. Go to Administrative tools->Services. Check docker demon command line for service "Dock Engine"

enter image description here

The command line is something like

"C:\Program Files\Docker\Docker\Resources\dockerd.exe" --run-service --service-name docker -G myPc" --config-file C:\ProgramData\DockerDesktop\tmp-d4w\daemon.json

2) Edit the config file daemon.json and add the data-root property.Property value should point to desired location. Should look something like this. Check this for information on json structure.

{
  "registry-mirrors": [],
  "insecure-registries": [],
  "debug": true,
  "experimental": false,
  "hosts": [
  "npipe:////./pipe/docker_engine_windows"
  ],
  "data-root":"D:\\Docker\\data-root" 

}

If necessary, give permissions for the running account to access the folder.

3) restart the service. If doesn't start, check eventlog for possible errors.

Previous configured data in c:\ProgramData\Docker will be lost when you change the install location. It’s like a new install to a new location. (images, containers, etc). All sub folders will be created again.

To keep the minimum on system drive do this on a fresh install.

I am not 100% sure about this solution, but so far, docker is working fine and system drive occupation is slim.

| improve this answer | |
1

On Docker v19.03.8 for Windows, I added the graph parameter to my config, and it worked for me, but apparently, this parameter is deprecated and we should now use data-root instead. The default value for data-root is c:\programdata\docker. Beware that in the JSON configuration file the backslashes need to be escaped.

enter image description here

| improve this answer | |
1

This answer is more an addition at Jean-François Beauchamp's answer :
You can find full documentation about this config file on Docker's documentation.

It is stated :

--data-root is the path where persisted data such as images, volumes, and cluster state are stored.

and

--exec-root is the path where the container state is stored. The default value is /var/run/docker. Specify the path for your running daemon here.

So if you want to move both your containers and images (and the other stuff), you have to set both of these parameter.

You can also create a simple link where Docker expects its folder to redirect to the desired place.
It is described here and lead to the same result. It looks "dirty" but in the end it looks more stable than the first solution.


Working with WSL 2 engine (for Windows Home and Family Editions)

"D:\\Docker\\data-root" value as suggested by Miguel will crash Docker because it has to be a WSL folder.
However, Docker create a specific WSL distro which contains your docker data, and you can move it. This does not require to modify dockerd parameters.

To move docker's WSL distro

 wsl --export docker-desktop-data docker-desktop-data.tar
 wsl --unregister docker-desktop-data
 wsl --import docker-desktop-data X:\wslStore\ docker-desktop-data.tar --version 2

The X:\wslStore param is the path where you want to "mount" your Distro, something like D:\Docker\data-root

| improve this answer | |
  • my docker boots up but my data aren't persistent, here's another problem ... – Maxime.D Jul 15 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.