added info files
This commit is contained in:
25
linux/docker change storage.md
Normal file
25
linux/docker change storage.md
Normal file
@ -0,0 +1,25 @@
|
||||
Stop the Docker daemon:
|
||||
>sudo systemctl stop docker
|
||||
Copy existing Docker data: If you already have images, containers, and volumes that you want to keep, you'll need to move them to the new location. Replace /new/path with the path to the directory where you want Docker to store its data.
|
||||
|
||||
>sudo rsync -aP /var/lib/docker/ /new/path/docker
|
||||
Edit the Docker configuration file: Open the Docker configuration file with a text editor like nano or vi. The location of this file might vary depending on your Linux distribution, but it's typically found at /etc/docker/daemon.json. If the file doesn't exist, create it.
|
||||
|
||||
|
||||
>sudo nano /etc/docker/daemon.json
|
||||
Then add the following content, again replacing /new/path with your desired path:
|
||||
|
||||
|
||||
{
|
||||
"data-root": "/new/path/docker"
|
||||
}
|
||||
Save and close the file.
|
||||
|
||||
Start Docker again:
|
||||
>sudo systemctl start docker
|
||||
Verify the changes: Run a command like docker info | grep "Docker Root Dir" to ensure that Docker is using the new directory.
|
||||
|
||||
Optional - Clean up old data: If everything is working fine, and you have made a backup, you may want to remove the old Docker directory to free up space:
|
||||
|
||||
|
||||
>sudo rm -rf /var/lib/docker/
|
Reference in New Issue
Block a user