Change the default Docker storage location

Hello,
I want to change the default Docker storage location to another hard disk, a SAN or a NAS. I have a few questions:

1- I found two articles How to change Docker storage location - Dmytro Kryvokhyzha and https://linuxconfig.org/how-to-move-docker-s-default-var-lib-docker-to-another-directory-on-ubuntu-debian-linux. Which one is good?

2- What kind of file system is more suitable for this task and has a higher speed?

Cheers.

A local NVMe SSD has higher speed, everything across wire (NAS on LAN) will usually be slower.

1 Like

Hi,
Thank you so much for your reply.
Which of those tutorials is suitable for changing the default Docker storage?

I would use the last part of the first link: edit /etc/docker/daemon.json and add or change the data directory setting.

1 Like

Hello,
Thank you so much for your reply.
1- It is written in the article that the old containers remain in the /etc/default/docker address. Can’t they be moved to a new location and not downloaded again?

2- There are a number of directories, each containing a YAML file. Is it possible to tell Docker to automatically check and download all YAML files?

Hello,
I stopped Docker:

# systemctl stop docker

Then, I did the following steps:

# touch /etc/docker/daemon.json
# nano /etc/docker/daemon.json
{
 "data-root": "/mnt/new"
}

After it, I moved /var/lib/docker directory to /mnt/new directory and started the Docker service:

# systemctl start docker

But, when I use docker compose up -d, then it wants to download all the containers again.

What is wrong?

Hello,
Problem solved.
I modified the daemon.json file as below:

{
 "data-root": "/mnt/new/docker"
}