Unable to Change Docker Default Root Data Directory

Dear Mentors,

I am using Ubuntu on WSL2.

I would like to shift the default Docker root data directory from /var/lib/docker to a folder in D drive, which is properly mounted on default, it can be accessed, added file, and deleted file.

I have learned that the default Docker root data directory can be shifted by modifying this file /etc/docker/daemon.json.

I have created this file with the following code to override the default configuration

{
“data-root”: “/mnt/d/ubuntu_docker_repo/”
}

/mnt/d is mounted by default when i was setting up Ubuntu on WSL2.

after that, i run this command

sudo systemctl restart docker

However, it was failed with the following error:

Job for docker.service failed because the control process exited with error code.
See “systemctl status docker.service” and “journalctl -xeu docker.service” for details.

systemctl status docker.service

× docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2024-08-08 20:47:12 +08; 2min 16s ago
TriggeredBy: × docker.socket

Process: 458 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, statu>

Main PID: 458 (code=exited, status=1/FAILURE)

Aug 08 20:47:12 Unknown systemd[1]: Stopped Docker Application Container Engine.
Aug 08 20:47:12 Unknown systemd[1]: docker.service: Start request repeated too quickly.
Aug 08 20:47:12 Unknown systemd[1]: docker.service: Failed with result ‘exit-code’.
Aug 08 20:47:12 Unknown systemd[1]: Failed to start Docker Application Container Engine.
lines 1-12/12 (END)

journalctl -xeu docker.service

░░ Subject: A start job for unit docker.service has failed
░░ Defined-By: systemd
░░
░░
░░ A start job for unit docker.service has finished with a failure.
░░
░░ The job identifier is 369 and the job result is failed.
Aug 08 20:47:12 Unknown systemd[1]: Stopped Docker Application Container Engine.
░░ Subject: A stop job for unit docker.service has finished
░░ Defined-By: systemd
░░
░░
░░ A stop job for unit docker.service has finished.
░░
░░ The job identifier is 427 and the job result is done.
Aug 08 20:47:12 Unknown systemd[1]: docker.service: Start request repeated too quickly.
Aug 08 20:47:12 Unknown systemd[1]: docker.service: Failed with result ‘exit-code’.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit docker.service has entered the ‘failed’ state with result ‘exit-code’.
Aug 08 20:47:12 Unknown systemd[1]: Failed to start Docker Application Container Engine.
░░ Subject: A start job for unit docker.service has failed
░░ Defined-By: systemd
░░
░░
░░ A start job for unit docker.service has finished with a failure.
░░
░░ The job identifier is 427 and the job result is failed.
lines 450-479/479 (END)

I have tried to change the data-root directory to a test folder, which i simply created, but it works!

{
“data-root”: “/mnt/test/”
}

So there is a conclusion on this issue, if i point the data-root to C drive and D drive in Windows OS, it causes an error. But if i point the data-root to any local folder within the Ubuntu OS, it is working fine.

Could you please guide me a solution on this issue? I have to store the Docker image in D drive, which is my external storage.

Thank you

Wait what? You installed Docker Desktop for Linux inside a WSL2 distribution instead of installing Docker Desktop for Windows?

Anyway, the data root folder must be on a supported backing filesysteme
https://docs.docker.com/storage/storagedriver/select-storage-driver/#supported-backing-filesystems

If you write C and D drive, then it’s most likely ntfs, and such not a supported backing filesystem.

1 Like

I see the issue is solved, but I would like to note that if you don’t want to confuse people, it is recommended to respond questions like this even if you solved the issue:

The fact that you change the daemon json to move the docker data root shows that you don’t use Docker Desktop. You use Docker CE, but it will not be obvious to everyone. I moved the topic to the right category.