Modifying the default storage container path Docker

The default installation services after docker root path for the data storage / under var / lib / docker directory, var directory is used by default root partition of disk space; so this is a very dangerous thing; as we mirror, container instance starts in the beginning increased when the disk space consumed will be growing, so we have to do the default storage location and data migration path to modify docker services; there are many ways that you can modify the default storage directory path docker, but the best after the installation is complete docker, the first time they modify the default storage location path docker for other large catalog disk space (for general corporate / data directory), to avoid the risk of data migration process caused.

( 1 ) Create a docker container storage path
 # mkdir -p / Home / Data / docker / lib
( 2 ) Stop Docker services and migrate data to a new directory
 # systemctl STOP docker.service 
# rsync -avz / var / lib / Docker / / Home / the Data / Docker / lib /
( 3 ) create a configuration file Docker 
# mkdir -p /etc/systemd/system/docker.service.d/  
# vim /etc/systemd/system/docker.service.d/ devicemapper.conf 
[Service] 
ExecStart = 
ExecStart = / usr / bin / dockerd --graph = / home / data / docker / lib /
( 4 ) to restart the service Docker 
# systemctl daemon - reload 
# systemctl restart Docker
( 5 ) Check the container is now stored in the directory 
# Docker info | grep  " Dir " 
  Docker Root Dir: / Home / the Data / Docker / lib

 

Guess you like

Origin www.cnblogs.com/douh/p/12560439.html