{"id":259645,"date":"2023-01-08T08:17:41","date_gmt":"2023-01-08T00:17:41","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=259645"},"modified":"2022-12-24T12:18:50","modified_gmt":"2022-12-24T04:18:50","slug":"sudo-docker","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/sudo-docker.html","title":{"rendered":"\u4e0d\u5e94\u8be5\u5728\u6ca1\u6709 sudo \u7684\u60c5\u51b5\u4e0b\u8fd0\u884c Docker \u7684\u539f\u56e0"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u60a8\u9700\u8981 root \u6743\u9650\u624d\u80fd\u5728 Linux \u4e0a\u8fd0\u884c\u4efb\u4f55\u4e0e Docker \u76f8\u5173\u7684\u547d\u4ee4\u3002\u5f53\u7136\uff0c\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u60a8\u53ef\u4ee5\u66f4\u6539\u6b64\u8bbe\u7f6e\u5e76\u5728\u6ca1\u6709 root \u6743\u9650\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c Docker \u547d\u4ee4\uff0c\u4f46\u60a8\u5e94\u8be5\u6ce8\u610f\u5b89\u5168\u9690\u60a3\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Docker \u662f\u5f00\u53d1\u4eba\u5458\u7684\u5b89\u5168\u5bb9\u5668\u5316\u5e73\u53f0\u3002\u65e2\u7136\u5b83\u5982\u6b64\u5b89\u5168\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u5728\u6ca1\u6709\u8d85\u7ea7\u7528\u6237\u6743\u9650\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u5b83\uff1f<\/p>\n

Docker \u662f\u6700\u5e38\u7528\u7684\u5bb9\u5668\u5316\u5e73\u53f0\u4e4b\u4e00\uff0c\u6df1\u53d7\u8f6f\u4ef6\u5de5\u7a0b\u5e08\u7684\u559c\u7231\u3002\u5b83\u5e26\u6709\u4e00\u4e2a\u5f3a\u5927\u7684 CLI \u5de5\u5177\uff0c\u7528\u4e8e\u7ba1\u7406 Docker \u5bb9\u5668\u548c\u5176\u4ed6\u76f8\u5173\u4efb\u52a1\u3002<\/p>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u60a8\u9700\u8981 root \u6743\u9650\u624d\u80fd\u5728 Linux \u4e0a\u8fd0\u884c\u4efb\u4f55\u4e0e Docker \u76f8\u5173\u7684\u547d\u4ee4\u3002\u5f53\u7136\uff0c\u4e3a\u4e86\u65b9\u4fbf\u8d77\u89c1\uff0c\u60a8\u53ef\u4ee5\u66f4\u6539\u6b64\u8bbe\u7f6e\u5e76\u5728\u6ca1\u6709 root \u6743\u9650\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c Docker \u547d\u4ee4\uff0c\u4f46\u60a8\u5e94\u8be5\u6ce8\u610f\u5b89\u5168\u9690\u60a3\u3002<\/p>\n

\"\"<\/a><\/p>\n

\u4ec0\u4e48\u662f Docker \u653b\u51fb\u9762\uff1f<\/strong><\/div>\n

\u653b\u51fb\u9762\u662f\u6076\u610f\u7528\u6237\u53ef\u4ee5\u7528\u6765\u8fdb\u5165\u7cfb\u7edf\u5e76\u9020\u6210\u4e25\u91cd\u7834\u574f\u7684\u653b\u51fb\u70b9\u6570\u91cf\uff0c\u66f4\u50cf\u662f\u7a97\u53e3\u6570\u91cf\u3002\u6839\u636e\u7ecf\u9a8c\uff0cIT \u7cfb\u7edf\u5e94\u5177\u6709\u6700\u5c0f\u7684\u653b\u51fb\u9762\uff0c\u4ee5\u964d\u4f4e\u5b89\u5168\u98ce\u9669\u3002<\/p>\n

\u4e00\u822c\u6765\u8bf4\uff0cDocker \u7684\u653b\u51fb\u9762\u975e\u5e38\u5c0f\u3002\u5bb9\u5668\u5728\u5b89\u5168\u7684\u9694\u79bb\u73af\u5883\u4e2d\u8fd0\u884c\uff0c\u9664\u975e\u53e6\u6709\u89c4\u5b9a\uff0c\u5426\u5219\u4e0d\u4f1a\u5f71\u54cd\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u3002\u6b64\u5916\uff0cDocker \u5bb9\u5668\u53ea\u8fd0\u884c\u6700\u5c11\u7684\u670d\u52a1\uff0c\u8fd9\u4f7f\u5f97\u5b83\u66f4\u5b89\u5168\u3002<\/p>\n

\u60a8\u53ef\u4ee5\u5c06 Linux \u7cfb\u7edf\u914d\u7f6e\u4e3a\u5728\u6ca1\u6709 sudo \u6743\u9650\u7684\u60c5\u51b5\u4e0b\u63a7\u5236 Docker\u3002\u8fd9\u5728\u5f00\u53d1\u73af\u5883\u4e2d\u53ef\u80fd\u5f88\u65b9\u4fbf\uff0c\u4f46\u5728\u751f\u4ea7\u7cfb\u7edf\u4e2d\u53ef\u80fd\u662f\u4e00\u4e2a\u4e25\u91cd\u7684\u5b89\u5168\u6f0f\u6d1e\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4f60\u6c38\u8fdc\u4e0d\u5e94\u8be5\u5728\u6ca1\u6709 sudo \u7684\u60c5\u51b5\u4e0b\u8fd0\u884c Docker\u3002<\/p>\n

1. \u80fd\u591f\u63a7\u5236 Docker \u5bb9\u5668<\/strong><\/span><\/div>\n

\u5982\u679c\u6ca1\u6709 sudo \u6743\u9650\uff0c\u4efb\u4f55\u6709\u6743\u8bbf\u95ee\u60a8\u7684\u7cfb\u7edf\u6216\u670d\u52a1\u5668\u7684\u4eba\u90fd\u53ef\u4ee5\u63a7\u5236 Docker \u7684\u5404\u4e2a\u65b9\u9762\u3002\u4ed6\u4eec\u6709\u6743\u8bbf\u95ee\u60a8\u7684 Docker \u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u4e14\u53ef\u4ee5\u968f\u610f\u6216\u610f\u5916\u5730\u505c\u6b62\u548c\u5220\u9664\u5bb9\u5668\u3002\u60a8\u8fd8\u53ef\u80fd\u4e22\u5931\u5bf9\u4e1a\u52a1\u8fde\u7eed\u6027\u81f3\u5173\u91cd\u8981\u7684\u5173\u952e\u6570\u636e\u3002<\/p>\n

\u5982\u679c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528 Docker \u5bb9\u5668\uff0c\u505c\u673a\u4f1a\u5bfc\u81f4\u4e1a\u52a1\u548c\u4fe1\u4efb\u635f\u5931\u3002<\/p>\n

2. \u83b7\u5f97\u5bf9\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u76ee\u5f55\u7684\u63a7\u5236<\/strong><\/span><\/div>\n

Docker \u5377\u662f\u4e00\u9879\u529f\u80fd\u5f3a\u5927\u7684\u670d\u52a1\uff0c\u5141\u8bb8\u60a8\u901a\u8fc7\u5c06\u5bb9\u5668\u6570\u636e\u5199\u5165\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u7684\u6307\u5b9a\u6587\u4ef6\u5939\u6765\u5171\u4eab\u548c\u4fdd\u7559\u5bb9\u5668\u6570\u636e\u3002<\/p>\n

\u5728\u6ca1\u6709 sudo \u7684\u60c5\u51b5\u4e0b\u8fd0\u884c Docker \u5e26\u6765\u7684\u6700\u5927\u5a01\u80c1\u4e4b\u4e00\u662f\u7cfb\u7edf\u4e0a\u7684\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u63a7\u5236\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u7684\u76ee\u5f55\uff0c\u5305\u62ec\u6839\u76ee\u5f55\u3002<\/p>\n

\u60a8\u6240\u8981\u505a\u7684\u5c31\u662f\u8fd0\u884c Linux Docker \u6620\u50cf\uff0c\u4f8b\u5982 Ubuntu \u6620\u50cf\uff0c\u5e76\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u5176\u6302\u8f7d\u5230\u6839\u6587\u4ef6\u5939\u4e0a\uff1a<\/p>\n

root@linuxmi:\/home\/linuxmi\/www.linuxmi.com# docker run -ti -v \/:\/hostproot ubuntu bash\r\n<\/pre>\n

\u8f93\u51fa\u5982\u4e0b\uff1a<\/p>\n

Unable to find image 'ubuntu:latest' locally\r\nlatest: Pulling from library\/ubuntu\r\n6e3729cf69e0: Pull complete \r\nDigest: sha256:27cb6e6ccef575a4698b66f5de06c7ecd61589132d5a91d098f7f3f9285415a9\r\nStatus: Downloaded newer image for ubuntu:latest\r\n<\/pre>\n

\u7531\u4e8e Linux Docker \u5bb9\u5668\u4ee5 root \u7528\u6237\u8eab\u4efd\u8fd0\u884c\uff0c\u56e0\u6b64\u672c\u8d28\u4e0a\u610f\u5473\u7740\u60a8\u53ef\u4ee5\u8bbf\u95ee\u6574\u4e2a\u6839\u6587\u4ef6\u5939\u3002<\/p>\n

\u4e0a\u8ff0\u547d\u4ee4\u5c06\u4e0b\u8f7d\u5e76\u8fd0\u884c\u6700\u65b0\u7684 Ubuntu \u6620\u50cf\u5e76\u5c06\u5176\u6302\u8f7d\u5230\u6839\u76ee\u5f55\u4e0a\u3002<\/p>\n

\u5728 Docker \u5bb9\u5668\u7ec8\u7aef\u4e0a\uff0c\u4f7f\u7528 cd \u547d\u4ee4\u8f6c\u5230 \/hostproot \u76ee\u5f55\uff1a<\/p>\n

root@c977c6de6265:\/# cd \/hostproot\r\n<\/pre>\n

\u4f7f\u7528 ls \u547d\u4ee4\u5217\u51fa\u6b64\u76ee\u5f55\u7684\u5185\u5bb9\u5c06\u663e\u793a\u5bb9\u5668\u4e2d\u73b0\u5728\u53ef\u7528\u7684\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u7684\u6240\u6709\u6587\u4ef6\u3002\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u64cd\u4f5c\u6587\u4ef6\uff0c\u67e5\u770b\u673a\u5bc6\u6587\u4ef6\uff0c\u9690\u85cf\u548c\u53d6\u6d88\u9690\u85cf\u6587\u4ef6\uff0c\u66f4\u6539\u6743\u9650\u7b49\u3002<\/p>\n

3. \u5b89\u88c5\u6076\u610f\u8f6f\u4ef6<\/strong><\/span><\/div>\n

\u7cbe\u5fc3\u5236\u4f5c\u7684 Docker \u6620\u50cf\u53ef\u4ee5\u5728\u540e\u53f0\u8fd0\u884c\u5e76\u64cd\u4f5c\u7cfb\u7edf\u6216\u6536\u96c6\u654f\u611f\u6570\u636e\u3002\u66f4\u7cdf\u7cd5\u7684\u662f\uff0c\u6076\u610f\u7528\u6237\u53ef\u80fd\u4f1a\u901a\u8fc7 Docker \u5bb9\u5668\u5728\u60a8\u7684\u7f51\u7edc\u4e0a\u4f20\u64ad\u6076\u610f\u4ee3\u7801\u3002<\/p>\n

Docker \u5bb9\u5668\u6709\u51e0\u4e2a\u5b9e\u9645\u7528\u4f8b\uff0c\u6bcf\u4e2a\u5e94\u7528\u7a0b\u5e8f\u90fd\u4f1a\u5e26\u6765\u4e00\u7ec4\u4e0d\u540c\u7684\u5b89\u5168\u5a01\u80c1\u3002<\/p>\n

\u5728 Linux \u4e0a\u4fdd\u62a4\u60a8\u7684 Docker \u5bb9\u5668<\/strong><\/div>\n

Docker\u662f\u4e00\u4e2a\u5f3a\u5927\u800c\u5b89\u5168\u7684\u5e73\u53f0\u3002\u5728\u6ca1\u6709 sudo \u7684\u60c5\u51b5\u4e0b\u8fd0\u884c Docker \u4f1a\u589e\u52a0\u60a8\u7684\u653b\u51fb\u9762\u5e76\u4f7f\u60a8\u7684\u7cfb\u7edf\u5bb9\u6613\u53d7\u5230\u653b\u51fb\u3002\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u5f3a\u70c8\u5efa\u8bae\u60a8\u5c06 sudo \u4e0e Docker \u4e00\u8d77\u4f7f\u7528\u3002<\/p>\n

\u7531\u4e8e\u7cfb\u7edf\u4e0a\u6709\u5982\u6b64\u591a\u7684\u7528\u6237\uff0c\u56e0\u6b64\u5f88\u96be\u4e3a\u6bcf\u4e2a\u7528\u6237\u5206\u914d\u6743\u9650\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u9075\u5faa\u6700\u4f73\u8bbf\u95ee\u63a7\u5236\u5b9e\u8df5\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7ef4\u62a4\u7cfb\u7edf\u7684\u5b89\u5168\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Docker \u662f\u5f00\u53d1\u4eba\u5458\u7684\u5b89\u5168\u5bb9\u5668\u5316\u5e73\u53f0\u3002\u65e2\u7136\u5b83\u5982\u6b64\u5b89\u5168\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u5728\u6ca1\u6709\u8d85\u7ea7\u7528\u6237\u6743\u9650\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u5b83\uff1f Doc […]<\/p>\n","protected":false},"author":370,"featured_media":110911,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-259645","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\/259645","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\/370"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=259645"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/259645\/revisions"}],"predecessor-version":[{"id":259757,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/259645\/revisions\/259757"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/110911"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=259645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=259645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=259645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}