Change Docker Storage Path: Guide
To change the storage path of Docker, you need to edit the Docker configuration file and specify the new storage path. Here is how to modify the Docker storage path:
- Locate the configuration file for Docker. In most Linux systems, the configuration file for Docker can be found at /etc/docker/daemon.json. If the file does not exist, you can create a new one.
- Edit the configuration file. Open the configuration file with a text editor and add the following content:
{
"data-root": "/new/path/to/docker_data"
}
Replace /new/path/to/docker_data with the new path where you want to store Docker data.
- Save and close the configuration file.
- Restart the Docker service. You can restart the Docker service using the following command:
sudo systemctl restart docker
- Confirm if the changes have taken effect. You can use the following command to check if the storage path of Docker has been modified:
docker info | grep "Docker Root Dir"
If the output displays a new storage path, it means the modification has taken effect. If not, it may be due to an error in the configuration file or Docker service not being properly restarted. You can try repeating the above steps to resolve the issue.