{"id":231103,"date":"2021-12-10T09:31:28","date_gmt":"2021-12-10T01:31:28","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=231103"},"modified":"2021-11-28T17:32:15","modified_gmt":"2021-11-28T09:32:15","slug":"migrate-data-directory","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/migrate-data-directory.html","title":{"rendered":"docker\u5982\u4f55\u8fc1\u79fb\u6570\u636e\u76ee\u5f55"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u4e86docker\u8fc1\u79fb\u6570\u636e\u76ee\u5f55\u7684\u65b9\u6cd5\u6b65\u9aa4\uff0c\u6587\u4e2d\u901a\u8fc7\u793a\u4f8b\u4ee3\u7801\u4ecb\u7ecd\u7684\u975e\u5e38\u8be6\u7ec6\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u4eec\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u67e5\u770b\u78c1\u76d8\u4f7f\u7528<\/strong><\/div>\n
\r\n# du -hs \/var\/lib\/docker\/ \r\n237G    \/var\/lib\/docker\/\r\n \r\n# docker system df\r\nTYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE\r\nImages              7                   2                   122.2GB             79.07GB (64%)\r\nContainers          2                   2                   61.96GB             0B (0%)\r\nLocal Volumes       0                   0                   0B                  0B\r\nBuild Cache         0                   0                   0B                  0B\r\n<\/pre>\n
\u78c1\u76d8\u6e05\u7406 (\u5207\u52ff\u8f7b\u6613\u4f7f\u7528)<\/strong><\/div>\n
\r\n# docker system prune \u547d\u4ee4\u53ef\u4ee5\u7528\u4e8e\u6e05\u7406\u78c1\u76d8\uff0c\u5220\u9664\u5173\u95ed\u7684\u5bb9\u5668\u3001\u65e0\u7528\u7684\u6570\u636e\u5377\u548c\u7f51\u7edc\uff0c\u4ee5\u65e0tag\u7684\u955c\u50cf\u3002\r\n# docker system prune -a \u547d\u4ee4\u53ef\u4ee5\u5c06\u6ca1\u6709\u5bb9\u5668\u4f7f\u7528Docker\u955c\u50cf\u90fd\u5220\u6389\u3002\u6ce8\u610f\uff0c\u8fd9\u4e24\u4e2a\u547d\u4ee4\u4f1a\u628a\u6682\u65f6\u5173\u95ed\u7684\u5bb9\u5668\uff0c\u4ee5\u53ca\u6682\u65f6\u6ca1\u6709\u7528\u5230\u7684Docker\u955c\u50cf\u90fd\u5220\u6389\u3002\r\n<\/pre>\n
\u8fc1\u79fb\u6570\u636e<\/strong><\/div>\n
\r\n\u3010\u505cdocker\u3011\r\n# systemctl stop docker\r\n \r\n\u3010\u521b\u5efa\u65b0\u7684docker\u76ee\u5f55\u3011\r\n# mkdir -p \/home\/docker\/lib\r\n \r\n\u3010\u8fc1\u79fb \/var\/lib\/docker \u76ee\u5f55\u3011\r\n(\u6ce8\uff1a\u53ef\u76f4\u63a5mv\uff0c\u786e\u4fdd\u78c1\u76d8\u591f\u5927\uff09\r\n# rsync -avz \/var\/lib\/docker \/home\/docker\/lib\/  \r\n \r\n\u3010\u589e\u52a0\u914d\u7f6e\u3011\r\n\u67e5\u770b  \/etc\/systemd\/system\/docker.service.d\/devicemapper.conf\u662f\u5426\u5b58\u5728\u3002\u5982\u679c\u4e0d\u5b58\u5728\uff0c\u5c31\u65b0\u5efa\u3002\r\n# mkdir -p \/etc\/systemd\/system\/docker.service.d\/\r\n# vi \/etc\/systemd\/system\/docker.service.d\/devicemapper.conf\r\n (\u6ce8\uff1adevicemapper.conf \u589e\u52a0\u914d\u7f6e\uff1a\u540c\u6b65\u7684\u65f6\u5019\u628a\u7236\u6587\u4ef6\u5939\u4e00\u5e76\u540c\u6b65\u8fc7\u6765\uff0c\u5b9e\u9645\u4e0a\u7684\u76ee\u5f55\u5e94\u5728 \/home\/docker\/lib\/docker )\r\n[Service]\r\nExecStart=\r\nExecStart=\/usr\/bin\/dockerd  --graph=\/home\/docker\/lib\/docker\r\n \r\n\u3010\u91cd\u65b0\u52a0\u8f7d docker\u3011 \r\n# systemctl daemon-reload\r\n# systemctl restart docker\r\n# systemctl enable docker\r\n \r\n\u3010\u68c0\u67e5docker info\u3011\r\n# docker info | grep \"Docker Root Dir\"\r\n\u662f\u5426\u53d8\u66f4\u4e3a\uff1a \/home\/docker\/lib\/docker\r\n \r\n\u3010\u68c0\u67e5\u955c\u50cf\u3011\r\n# docker images\r\n \r\n\u3010\u6e05\u7406\u539f\u6570\u636e\u3011\r\n\u786e\u5b9a\u5bb9\u5668\u6ca1\u95ee\u9898\u540e\u5220\u9664\/var\/lib\/docker\/\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u3002\r\n# rm -rf \/var\/lib\/docker\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

# du -hs \/var\/lib\/docker\/ 237G \/var\/lib\/docker\/ # docke […]<\/p>\n","protected":false},"author":362,"featured_media":170013,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-231103","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/231103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=231103"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/231103\/revisions"}],"predecessor-version":[{"id":231106,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/231103\/revisions\/231106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/170013"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=231103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=231103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=231103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}