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.socketProcess: 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