{"id":46484,"date":"2025-07-30T03:16:23","date_gmt":"2025-07-29T19:16:23","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/46484.html"},"modified":"2025-07-30T03:16:23","modified_gmt":"2025-07-29T19:16:23","slug":"%e5%85%a8%e6%96%b0-ubuntu-%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%a0%87%e5%87%86%e9%85%8d%e7%bd%ae%e6%8c%87%e5%8d%97%ef%bc%88docker%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/46484.html","title":{"rendered":"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09"},"content":{"rendered":"<h2><\/h2>\n<p>\u672c\u6307\u5357\u65e8\u5728\u4e3a\u4e00\u53f0\u5168\u65b0\u7684 Ubuntu \u670d\u52a1\u5668\u63d0\u4f9b\u4e00\u5957\u5b8c\u6574\u3001\u9ad8\u6548\u7684\u6807\u51c6\u5316\u521d\u59cb\u914d\u7f6e\u6d41\u7a0b\u3002\u6d41\u7a0b\u6db5\u76d6\u4e86\u4ece\u7cfb\u7edf\u57fa\u7840\u8bbe\u5b9a\u3001\u9632\u706b\u5899\u914d\u7f6e\u5230 Docker \u73af\u5883\u5b89\u88c5\u4e0e\u4f18\u5316\u7684\u6240\u6709\u5173\u952e\u6b65\u9aa4\u3002\u60a8\u53ef\u4ee5\u6309\u7167\u672c\u6307\u5357\u7684\u987a\u5e8f\u9010\u4e00\u6267\u884c\u547d\u4ee4&#xff0c;\u4ee5\u5feb\u901f\u642d\u5efa\u4e00\u4e2a\u5b89\u5168\u3001\u7a33\u5b9a\u4e14\u9ad8\u6548\u7684\u670d\u52a1\u5668\u73af\u5883\u3002<\/p>\n<h4>\u7b2c\u4e00\u6b65&#xff1a;\u57fa\u7840\u7cfb\u7edf\u8bbe\u5b9a<\/h4>\n<p>\u6b64\u6b65\u9aa4\u5c06\u5b8c\u6210\u7cfb\u7edf\u66f4\u65b0\u3001\u66f4\u6362\u4e3a\u56fd\u5185\u9ad8\u901f\u8f6f\u4ef6\u6e90\u4ee5\u53ca\u5b89\u88c5\u5e38\u7528\u7684\u57fa\u7840\u5de5\u5177\u3002<\/p>\n<li>\n<p>\u66f4\u65b0\u5e76\u5347\u7ea7\u7cfb\u7edf<\/p>\n<p>\u786e\u4fdd\u7cfb\u7edf\u6240\u6709\u8f6f\u4ef6\u5305\u90fd\u5904\u4e8e\u6700\u65b0\u7684\u5b89\u5168\u72b6\u6001\u3002<\/p>\n<p>sudo apt-get update<br \/>\nsudo apt-get upgrade -y<\/p>\n<\/li>\n<li>\n<p>\u66f4\u6362\u7cfb\u7edf\u8f6f\u4ef6\u6e90\u4e3a\u963f\u91cc\u4e91\u955c\u50cf<\/p>\n<p>\u5927\u5e45\u63d0\u5347\u540e\u7eed\u8f6f\u4ef6\u7684\u5b89\u88c5\u4e0e\u66f4\u65b0\u901f\u5ea6\u3002<\/p>\n<ul>\n<li>\n<p>\u5907\u4efd\u539f\u59cb\u6587\u4ef6&#xff1a;<\/p>\n<p>sudo cp \/etc\/apt\/sources.list \/etc\/apt\/sources.list.bak<\/p>\n<\/li>\n<li>\n<p>\u7f16\u8f91\u6e90\u6587\u4ef6&#xff1a;<\/p>\n<p>sudo nano \/etc\/apt\/sources.list<\/p>\n<\/li>\n<li>\n<p>\u5220\u9664\u6587\u4ef6\u5185\u6240\u6709\u65e7\u5185\u5bb9&#xff0c;\u7136\u540e\u5b8c\u6574\u590d\u5236\u5e76\u7c98\u8d34\u4ee5\u4e0b\u9002\u7528\u4e8e Ubuntu 24.04 \u7684\u963f\u91cc\u4e91\u6e90\u5185\u5bb9&#xff1a;<\/p>\n<p>deb http:\/\/mirrors.aliyun.com\/ubuntu\/ noble main restricted universe multiverse<br \/>\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ noble main restricted universe multiverse<\/p>\n<p>deb http:\/\/mirrors.aliyun.com\/ubuntu\/ noble-updates main restricted universe multiverse<br \/>\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ noble-updates main restricted universe multiverse<\/p>\n<p>deb http:\/\/mirrors.aliyun.com\/ubuntu\/ noble-backports main restricted universe multiverse<br \/>\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ noble-backports main restricted universe multiverse<\/p>\n<p>deb http:\/\/mirrors.aliyun.com\/ubuntu\/ noble-security main restricted universe multiverse<br \/>\ndeb-src http:\/\/mirrors.aliyun.com\/ubuntu\/ noble-security main restricted universe multiverse<\/p>\n<\/li>\n<li>\n<p>\u4fdd\u5b58\u5e76\u9000\u51fa (\u5728 nano \u7f16\u8f91\u5668\u4e2d&#xff0c;\u6309 Ctrl&#043;X&#xff0c;\u7136\u540e\u6309 Y&#xff0c;\u6700\u540e\u6309 Enter)\u3002<\/p>\n<\/li>\n<li>\n<p>\u5237\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\u4ee5\u4f7f\u65b0\u6e90\u751f\u6548&#xff1a;<\/p>\n<p>sudo apt-get update<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5b89\u88c5\u5e38\u7528\u5de5\u5177\u96c6<\/p>\n<p>sudo apt-get install -y curl wget git vim htop net-tools<\/p>\n<\/li>\n<h4>\u7b2c\u4e8c\u6b65&#xff1a;\u9632\u706b\u5899 (UFW) \u8bbe\u5b9a<\/h4>\n<p>\u5efa\u7acb\u57fa\u7840\u7684\u7f51\u7edc\u5b89\u5168\u9632\u62a4&#xff0c;\u4ec5\u5f00\u653e\u5fc5\u8981\u7684\u670d\u52a1\u7aef\u53e3\u3002<\/p>\n<li>\n<p>\u8bbe\u5b9a\u9632\u706b\u5899\u89c4\u5219&#xff08;\u5148\u653e\u884c\u518d\u542f\u7528&#xff09;<\/p>\n<p># \u5141\u8bb8 SSH (\u7aef\u53e3 22)&#xff0c;\u8fd9\u662f\u6700\u91cd\u8981\u7684&#xff0c;\u9632\u6b62\u60a8\u88ab\u9501\u5728\u5916\u9762<br \/>\nsudo ufw allow ssh<\/p>\n<p># \u5141\u8bb8 HTTP (\u7aef\u53e3 80)&#xff0c;\u7528\u4e8e Web \u670d\u52a1<br \/>\nsudo ufw allow 80<\/p>\n<p># \u5141\u8bb8 HTTPS (\u7aef\u53e3 443)&#xff0c;\u7528\u4e8e\u5b89\u5168\u7684 Web \u670d\u52a1<br \/>\nsudo ufw allow 443<\/p>\n<\/li>\n<li>\n<p>\u542f\u7528\u9632\u706b\u5899<\/p>\n<p>sudo ufw enable<\/p>\n<p>(\u5f53\u7cfb\u7edf\u63d0\u793a Command may disrupt existing ssh connections \u65f6&#xff0c;\u8f93\u5165 y \u5e76\u6309 Enter)<\/p>\n<\/li>\n<li>\n<p>\u68c0\u67e5\u9632\u706b\u5899\u72b6\u6001&#xff0c;\u786e\u8ba4\u89c4\u5219\u5df2\u751f\u6548<\/p>\n<p>sudo ufw status verbose<\/p>\n<\/li>\n<h4>\u7b2c\u4e09\u6b65&#xff1a;Docker \u5b89\u88c5\u4e0e\u914d\u7f6e (\u5df2\u6574\u5408\u56fd\u5185\u955c\u50cf)<\/h4>\n<p>\u6b64\u6d41\u7a0b\u5c06\u76f4\u63a5\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u5b8c\u6210 Docker \u7684\u5b89\u88c5\u4e0e\u914d\u7f6e&#xff0c;\u786e\u4fdd\u5b89\u88c5\u548c\u540e\u7eed\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u7684\u901f\u5ea6\u3002<\/p>\n<li>\n<p>\u5b89\u88c5 Docker \u7684\u524d\u7f6e\u4f5c\u4e1a<\/p>\n<p>sudo apt-get install -y ca-certificates curl gnupg<\/p>\n<\/li>\n<li>\n<p>\u6dfb\u52a0 Docker \u5b98\u65b9 GPG \u5b89\u5168\u5bc6\u94a5<\/p>\n<p>sudo install -m 0755 -d \/etc\/apt\/keyrings<br \/>\ncurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg &#8211;dearmor -o \/etc\/apt\/keyrings\/docker.gpg<br \/>\nsudo chmod a&#043;r \/etc\/apt\/keyrings\/docker.gpg<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa Docker \u7684 APT \u8f6f\u4ef6\u6e90\u6587\u4ef6 (\u76f4\u63a5\u4f7f\u7528\u963f\u91cc\u4e91\u955c\u50cf)<\/p>\n<p>echo \\\\<br \/>\n  &#034;deb [arch&#061;$(dpkg &#8211;print-architecture) signed-by&#061;\/etc\/apt\/keyrings\/docker.gpg] https:\/\/mirrors.aliyun.com\/docker-ce\/linux\/ubuntu \\\\<br \/>\n  $(. \/etc\/os-release &amp;&amp; echo &#034;$VERSION_CODENAME&#034;) stable&#034; | \\\\<br \/>\n  sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5 Docker \u5f15\u64ce<\/p>\n<p>sudo apt-get update<br \/>\nsudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa Docker \u955c\u50cf\u52a0\u901f\u5668\u914d\u7f6e\u6587\u4ef6 (\u4f7f\u75282025\u5e747\u6708\u5b9e\u6d4b\u53ef\u7528\u955c\u50cf)<\/p>\n<p>\u6839\u636e\u6700\u65b0\u6d4b\u8bd5&#xff0c;\u591a\u4e2a\u65e7\u7684\u516c\u5171\u955c\u50cf\u7ad9\u5df2\u5931\u6548\u3002\u4ee5\u4e0b\u662f\u5f53\u524d\u5b9e\u6d4b\u53ef\u7528\u4e14\u7a33\u5b9a\u6027\u8f83\u9ad8\u7684\u516c\u5171\u955c\u50cf\u6e90\u3002<\/p>\n<ul>\n<li>\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff0c;\u914d\u7f6e Docker \u4f7f\u7528\u4e00\u7ec4\u53ef\u9760\u7684\u56fd\u5185\u955c\u50cf&#xff1a;<\/p>\n<p>sudo mkdir -p \/etc\/docker<br \/>\nsudo tee \/etc\/docker\/daemon.json &lt;&lt;-&#039;EOF&#039;<br \/>\n{<br \/>\n  &#034;registry-mirrors&#034;: [<br \/>\n    &#034;https:\/\/docker.xuanyuan.me&#034;,<br \/>\n    &#034;https:\/\/docker.1ms.run&#034;,<br \/>\n    &#034;https:\/\/docker.m.daocloud.io&#034;<br \/>\n  ]<br \/>\n}<br \/>\nEOF<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u91cd\u542f Docker \u670d\u52a1\u4f7f\u6240\u6709\u914d\u7f6e\u751f\u6548<\/p>\n<p>sudo systemctl restart docker<\/p>\n<\/li>\n<li>\n<p>\u5c06\u60a8\u5f53\u524d\u7684\u7528\u6237\u52a0\u5165 docker \u7528\u6237\u7ec4&#xff08;\u514d\u53bb sudo&#xff09;<\/p>\n<p>sudo usermod -aG docker $USER<\/p>\n<\/li>\n<h4>\u7b2c\u56db\u6b65&#xff1a;\u6700\u7ec8\u9a8c\u8bc1<\/h4>\n<li>\n<p>\u767b\u51fa\u5e76\u91cd\u65b0\u767b\u5165<\/p>\n<p>\u8bf7\u7acb\u5373\u65ad\u5f00\u60a8\u5f53\u524d\u7684 SSH \u8fde\u63a5&#xff0c;\u7136\u540e\u91cd\u65b0\u767b\u5165\u4e00\u6b21\u60a8\u7684\u670d\u52a1\u5668\u3002 \u8fd9\u6837\u7528\u6237\u7ec4\u6743\u9650\u7684\u53d8\u66f4\u624d\u4f1a\u5b8c\u5168\u751f\u6548\u3002<\/p>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1\u914d\u7f6e\u4e0e\u8fd0\u884c\u72b6\u6001<\/p>\n<p>\u5728\u60a8\u91cd\u65b0\u767b\u5165\u670d\u52a1\u5668\u4e4b\u540e&#xff0c;\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u9a8c\u8bc1\u955c\u50cf\u52a0\u901f\u5668\u662f\u5426\u751f\u6548&#xff1a;<\/p>\n<p>docker info | grep -A 3 -i &#034;Registry Mirrors&#034;<\/p>\n<p>(\u60a8\u5e94\u8be5\u80fd\u770b\u5230\u5df2\u914d\u7f6e\u7684\u955c\u50cf\u5730\u5740\u5217\u8868)<\/p>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1 Docker \u662f\u5426\u80fd\u6b63\u5e38\u8fd0\u884c&#xff1a;<\/p>\n<p>docker run hello-world<\/p>\n<p>(\u60a8\u5e94\u8be5\u80fd\u770b\u5230 &#034;Hello from Docker!&#034; \u7684\u6210\u529f\u4fe1\u606f)<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1\u955c\u50cf\u662f\u4ece\u54ea\u4e2a\u52a0\u901f\u5668\u62c9\u53d6\u7684 (\u53ef\u9009\u7684\u9ad8\u7ea7\u6280\u5de7)<\/p>\n<p>docker inspect \u547d\u4ee4\u901a\u5e38\u53ea\u4f1a\u663e\u793a\u955c\u50cf\u7684\u5b98\u65b9\u6765\u6e90 (docker.io)&#xff0c;\u800c\u4e0d\u4f1a\u663e\u793a\u5b83\u662f\u4ece\u54ea\u4e2a\u955c\u50cf\u52a0\u901f\u5668\u4e0b\u8f7d\u7684\u3002\u8981\u67e5\u770b\u8be6\u7ec6\u7684\u62c9\u53d6\u8fc7\u7a0b&#xff0c;\u6700\u53ef\u9760\u7684\u65b9\u6cd5\u662f\u76d1\u63a7 Docker \u670d\u52a1\u7684\u5b9e\u65f6\u65e5\u5fd7\u3002<\/p>\n<ul>\n<li>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u5220\u9664\u672c\u5730\u5df2\u6709\u7684\u955c\u50cf (\u4ee5\u4fbf\u91cd\u65b0\u62c9\u53d6)<\/p>\n<p>docker rmi hello-world<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u5728\u4e00\u4e2a\u7ec8\u7aef\u7a97\u53e3\u4e2d&#xff0c;\u5f00\u59cb\u76d1\u63a7 Docker \u65e5\u5fd7<\/p>\n<p>sudo journalctl -fu docker.service<\/p>\n<p>(\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u6301\u7eed\u6253\u5370\u65b0\u7684\u65e5\u5fd7&#xff0c;\u8bf7\u4fdd\u6301\u8fd9\u4e2a\u7ec8\u7aef\u7a97\u53e3\u6253\u5f00)<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u6253\u5f00\u53e6\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u7a97\u53e3&#xff0c;\u6267\u884c\u62c9\u53d6\u547d\u4ee4<\/p>\n<p>docker pull hello-world<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u89c2\u5bdf\u7b2c\u4e00\u4e2a\u7a97\u53e3\u7684\u65e5\u5fd7\u8f93\u51fa<\/p>\n<p>\u5728\u65e5\u5fd7\u4e2d&#xff0c;\u4f60\u4f1a\u770b\u5230 Docker \u6309\u987a\u5e8f\u5c1d\u8bd5\u8fde\u63a5\u4f60\u5728 daemon.json \u4e2d\u914d\u7f6e\u7684\u955c\u50cf\u7ad9\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u5931\u8d25&#xff0c;\u5b83\u4f1a\u5c1d\u8bd5\u7b2c\u4e8c\u4e2a&#xff0c;\u4ee5\u6b64\u7c7b\u63a8\u3002\u901a\u8fc7\u89c2\u5bdf\u65e5\u5fd7\u4e2d\u7684\u7f51\u7edc\u8bf7\u6c42\u5730\u5740&#xff0c;\u60a8\u5c31\u53ef\u4ee5\u5224\u65ad\u51fa\u6700\u7ec8\u662f\u4ece\u54ea\u4e2a\u955c\u50cf\u7ad9\u6210\u529f\u62c9\u53d6\u4e86\u955c\u50cf\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h4>\u26a0\ufe0f \u7279\u522b\u63d0\u9192&#xff1a;\u5173\u4e8e\u672c\u5730\u673a\u623f\u7684DNS\u95ee\u9898<\/h4>\n<p>\u8bf7\u6ce8\u610f&#xff0c;\u4ee5\u4e0a\u662f\u4e00\u5957\u5728\u6b63\u5e38\u7f51\u7edc\u73af\u5883\u4e0b\u7684\u6807\u51c6\u914d\u7f6e\u6d41\u7a0b\u3002<\/p>\n<p>\u6839\u636e\u6211\u4eec\u4e4b\u524d\u7684\u6392\u9519\u7ecf\u9a8c&#xff0c;\u5982\u679c\u60a8\u7684\u670d\u52a1\u5668\u5904\u4e8e\u6709\u4e25\u683c\u7f51\u7edc\u7b56\u7565\u7684\u672c\u5730\u673a\u623f&#xff0c;\u53ef\u80fd\u4f1a\u9047\u5230 DNS \u9650\u5236\u95ee\u9898\u3002\u5982\u679c\u60a8\u5728\u6267\u884c docker run hello-world \u65f6\u518d\u6b21\u9047\u5230 Name or service not known \u6216\u7f51\u7edc\u8d85\u65f6\u9519\u8bef&#xff0c;\u8fd9\u610f\u5473\u7740\u8fd9\u53f0\u65b0\u670d\u52a1\u5668\u4e5f\u53d7\u5230\u4e86\u540c\u6837\u7684\u7f51\u7edc\u7b56\u7565\u9650\u5236\u3002<\/p>\n<p>\u5c4a\u65f6&#xff0c;\u60a8\u9700\u8981\u4f18\u5148\u8054\u7cfb\u60a8\u7684\u7f51\u7edc\u7ba1\u7406\u5458&#xff0c;\u8bf7\u6c42\u4ed6\u4eec\u4e3a\u60a8\u7684\u670d\u52a1\u5668IP\u653e\u884c\u5bf9\u4ee5\u4e0b\u57df\u540d\u7684\u89e3\u6790\u548c\u8bbf\u95ee&#xff1a;<\/p>\n<ul>\n<li>\n<p>docker.xuanyuan.me<\/p>\n<\/li>\n<li>\n<p>docker.1ms.run<\/p>\n<\/li>\n<li>\n<p>docker.m.daocloud.io<\/p>\n<\/li>\n<\/ul>\n<h4>\u9644\u5f55&#xff1a;\u6df1\u5ea6\u7591\u96be\u6392\u89e3 (\u5f53\u6240\u6709\u65b9\u6cd5\u90fd\u5931\u6548\u65f6)<\/h4>\n<p>\u5982\u679c\u60a8\u4e25\u683c\u6267\u884c\u4e86\u4ee5\u4e0a\u6240\u6709\u6b65\u9aa4&#xff0c;\u5305\u62ec\u91cd\u542f\u670d\u52a1\u5668&#xff0c;\u4f46 docker info \u4e2d\u7684 Registry Mirrors \u4f9d\u7136\u4e3a\u7a7a&#xff0c;\u8fd9\u8868\u660e\u60a8\u7684\u7cfb\u7edf\u73af\u5883\u5b58\u5728\u975e\u5e38\u7279\u6b8a\u4e14\u987d\u56fa\u7684\u914d\u7f6e\u95ee\u9898&#xff0c;\u5bfc\u81f4 Docker \u670d\u52a1\u65e0\u6cd5\u52a0\u8f7d\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002<\/p>\n<p>\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u6700\u7ec8\u8bca\u65ad\u548c\u4fee\u590d\u3002<\/p>\n<p>1. \u5f3a\u5236 Docker \u670d\u52a1\u52a0\u8f7d\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u6b64\u65b9\u6cd5\u5c06\u4fee\u6539 Docker \u7684\u7cfb\u7edf\u670d\u52a1\u5355\u5143&#xff0c;\u5f3a\u5236\u5176\u5728\u542f\u52a8\u65f6\u5fc5\u987b\u8bfb\u53d6\u6211\u4eec\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<ul>\n<li>\n<p>\u7b2c\u4e00\u6b65&#xff1a;\u521b\u5efa systemd \u8986\u76d6\u6587\u4ef6<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u6253\u5f00\u4e00\u4e2a\u7a7a\u7684\u7f16\u8f91\u5668&#xff0c;\u7528\u4e8e\u5b89\u5168\u5730\u4fee\u6539 Docker \u7684\u542f\u52a8\u884c\u4e3a\u3002<\/p>\n<p>sudo systemctl edit docker.service<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e8c\u6b65&#xff1a;\u7c98\u8d34\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<p>\u8bf7\u5c06\u4e0b\u9762\u7684\u6240\u6709\u5185\u5bb9&#xff0c;\u5b8c\u6574\u5730\u590d\u5236\u5e76\u7c98\u8d34\u5230\u521a\u521a\u6253\u5f00\u7684\u7f16\u8f91\u5668\u4e2d\u3002<\/p>\n<p>[Service]<br \/>\nExecStart&#061;<br \/>\nExecStart&#061;\/usr\/bin\/dockerd &#8211;config-file \/etc\/docker\/daemon.json -H fd:\/\/ &#8211;containerd&#061;\/run\/containerd\/containerd.sock<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e09\u6b65&#xff1a;\u4fdd\u5b58\u5e76\u9000\u51fa (Ctrl&#043;X, Y, Enter)\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u56db\u6b65&#xff1a;\u7528\u6700\u5f7b\u5e95\u7684\u65b9\u5f0f\u91cd\u542f\u670d\u52a1<\/p>\n<p>\u8fd9\u4e2a\u987a\u5e8f\u5c06\u786e\u4fdd\u6240\u6709\u65e7\u7684\u914d\u7f6e\u548c\u72b6\u6001\u88ab\u6e05\u9664\u3002<\/p>\n<p>sudo systemctl stop docker.socket<br \/>\nsudo systemctl stop docker.service<br \/>\nsudo systemctl daemon-reload<br \/>\nsudo systemctl start docker.service<\/p>\n<\/li>\n<li>\n<p>\u7b2c\u4e94\u6b65&#xff1a;\u518d\u6b21\u9a8c\u8bc1<\/p>\n<p>docker info | grep -A 3 -i &#034;Registry Mirrors&#034;<\/p>\n<p>\u6267\u884c\u5b8c\u6b64\u6b65\u9aa4\u540e&#xff0c;\u955c\u50cf\u52a0\u901f\u5668\u7406\u5e94\u751f\u6548\u3002\u5982\u679c\u4f9d\u7136\u65e0\u6548&#xff0c;\u8bf7\u7ee7\u7eed\u4e0b\u4e00\u6b65\u3002<\/p>\n<\/li>\n<\/ul>\n<p>2. \u7ec8\u6781\u8bca\u65ad&#xff1a;\u67e5\u770b systemd \u52a0\u8f7d\u7684\u6700\u7ec8\u914d\u7f6e<\/p>\n<p>\u8ba9\u6211\u4eec\u770b\u770b systemd \u6700\u7ec8\u201c\u5b66\u4e60\u201d\u5230\u7684 Docker \u542f\u52a8\u547d\u4ee4\u5230\u5e95\u662f\u4ec0\u4e48\u3002<\/p>\n<ul>\n<li>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4&#xff1a;<\/p>\n<p>systemctl cat docker.service<\/p>\n<\/li>\n<li>\n<p>\u5206\u6790\u8f93\u51fa&#xff1a;<\/p>\n<p>\u8bf7\u68c0\u67e5\u8f93\u51fa\u5185\u5bb9\u3002\u5728 # \/etc\/systemd\/system\/docker.service.d\/override.conf \u8fd9\u4e00\u884c\u4e0b\u9762&#xff0c;\u60a8\u5fc5\u987b\u770b\u5230\u6211\u4eec\u6dfb\u52a0\u7684 ExecStart&#061;\/usr\/bin\/dockerd &#8211;config-file \/etc\/docker\/daemon.json &#8230; \u8fd9\u4e00\u884c\u3002<\/p>\n<ul>\n<li>\n<p>\u5982\u679c\u80fd\u770b\u5230&#xff0c;\u4f46 docker info \u4f9d\u7136\u65e0\u6548&#xff0c;\u8bf4\u660e Docker \u7a0b\u5e8f\u672c\u8eab\u53ef\u80fd\u5b58\u5728\u95ee\u9898\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u770b\u4e0d\u5230&#xff0c;\u8bf4\u660e systemd \u7531\u4e8e\u67d0\u79cd\u539f\u56e0\u5ffd\u7565\u4e86\u6211\u4eec\u7684\u4fee\u6539&#xff0c;\u8fd9\u53ef\u80fd\u662f\u7cfb\u7edf\u6743\u9650\u6216\u5b89\u5168\u6a21\u5757&#xff08;\u5982 AppArmor&#xff09;\u7684\u6df1\u5c42\u95ee\u9898\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728&#xff0c;\u8bf7\u8003\u8651\u8054\u7cfb\u4e13\u4e1a\u7684\u7cfb\u7edf\u7ba1\u7406\u5458\u6216\u670d\u52a1\u5668\u63d0\u4f9b\u5546\u4ee5\u83b7\u5f97\u8fdb\u4e00\u6b65\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb843\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u5728 # \/etc\/systemd\/system\/docker.service.d\/override.conf \u8fd9\u4e00\u884c\u4e0b\u9762\uff0c\u60a8\u5fc5\u987b\u770b\u5230\u6211\u4eec\u6dfb\u52a0\u7684 ExecStart=\/usr\/bin\/dockerd &#8211;config-file \/etc\/docker\/daemon.json &#8230; \u8fd9\u4e00\u884c\u3002\u4f9d\u7136\u4e3a\u7a7a\uff0c\u8fd9\u8868\u660e\u60a8\u7684\u7cfb\u7edf\u73af\u5883\u5b58\u5728\u975e\u5e38\u7279\u6b8a\u4e14\u987d\u56fa\u7684\u914d\u7f6e\u95ee\u9898\uff0c\u5bfc\u81f4 Docker \u670d\u52a1\u65e0\u6cd5\u52a0\u8f7d\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002\u8fd9\u6837\u7528\u6237\u7ec4\u6743\u9650\u7684\u53d8\u66f4\u624d\u4f1a\u5b8c\u5168\u751f\u6548\u3002\u6839\u636e\u6211\u4eec\u4e4b\u524d\u7684\u6392\u9519\u7ecf\u9a8c\uff0c\u5982\u679c\u60a8\u7684\u670d\u52a1\u5668\u5904\u4e8e\u6709\u4e25\u683c\u7f51\u7edc\u7b56\u7565\u7684\u672c\u5730\u673a\u623f\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u3002_ubuntu\u670d\u52a1\u5668\u521d\u59cb\u8bbe\u7f6e<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,103],"topic":[],"class_list":["post-46484","post","type-post","status-publish","format-standard","hentry","category-server","tag-docker","tag-ubuntu"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/46484.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb843\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u5728 # \/etc\/systemd\/system\/docker.service.d\/override.conf \u8fd9\u4e00\u884c\u4e0b\u9762\uff0c\u60a8\u5fc5\u987b\u770b\u5230\u6211\u4eec\u6dfb\u52a0\u7684 ExecStart=\/usr\/bin\/dockerd --config-file \/etc\/docker\/daemon.json ... \u8fd9\u4e00\u884c\u3002\u4f9d\u7136\u4e3a\u7a7a\uff0c\u8fd9\u8868\u660e\u60a8\u7684\u7cfb\u7edf\u73af\u5883\u5b58\u5728\u975e\u5e38\u7279\u6b8a\u4e14\u987d\u56fa\u7684\u914d\u7f6e\u95ee\u9898\uff0c\u5bfc\u81f4 Docker \u670d\u52a1\u65e0\u6cd5\u52a0\u8f7d\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002\u8fd9\u6837\u7528\u6237\u7ec4\u6743\u9650\u7684\u53d8\u66f4\u624d\u4f1a\u5b8c\u5168\u751f\u6548\u3002\u6839\u636e\u6211\u4eec\u4e4b\u524d\u7684\u6392\u9519\u7ecf\u9a8c\uff0c\u5982\u679c\u60a8\u7684\u670d\u52a1\u5668\u5904\u4e8e\u6709\u4e25\u683c\u7f51\u7edc\u7b56\u7565\u7684\u672c\u5730\u673a\u623f\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u3002_ubuntu\u670d\u52a1\u5668\u521d\u59cb\u8bbe\u7f6e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/46484.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-29T19:16:23+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/46484.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/46484.html\",\"name\":\"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-29T19:16:23+00:00\",\"dateModified\":\"2025-07-29T19:16:23+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/46484.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/46484.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/46484.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/46484.html","og_locale":"zh_CN","og_type":"article","og_title":"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb843\u6b21\uff0c\u70b9\u8d5e5\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u5728 # \/etc\/systemd\/system\/docker.service.d\/override.conf \u8fd9\u4e00\u884c\u4e0b\u9762\uff0c\u60a8\u5fc5\u987b\u770b\u5230\u6211\u4eec\u6dfb\u52a0\u7684 ExecStart=\/usr\/bin\/dockerd --config-file \/etc\/docker\/daemon.json ... \u8fd9\u4e00\u884c\u3002\u4f9d\u7136\u4e3a\u7a7a\uff0c\u8fd9\u8868\u660e\u60a8\u7684\u7cfb\u7edf\u73af\u5883\u5b58\u5728\u975e\u5e38\u7279\u6b8a\u4e14\u987d\u56fa\u7684\u914d\u7f6e\u95ee\u9898\uff0c\u5bfc\u81f4 Docker \u670d\u52a1\u65e0\u6cd5\u52a0\u8f7d\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002\u8fd9\u6837\u7528\u6237\u7ec4\u6743\u9650\u7684\u53d8\u66f4\u624d\u4f1a\u5b8c\u5168\u751f\u6548\u3002\u6839\u636e\u6211\u4eec\u4e4b\u524d\u7684\u6392\u9519\u7ecf\u9a8c\uff0c\u5982\u679c\u60a8\u7684\u670d\u52a1\u5668\u5904\u4e8e\u6709\u4e25\u683c\u7f51\u7edc\u7b56\u7565\u7684\u672c\u5730\u673a\u623f\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u3002_ubuntu\u670d\u52a1\u5668\u521d\u59cb\u8bbe\u7f6e","og_url":"https:\/\/www.wsisp.com\/helps\/46484.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-29T19:16:23+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/46484.html","url":"https:\/\/www.wsisp.com\/helps\/46484.html","name":"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-29T19:16:23+00:00","dateModified":"2025-07-29T19:16:23+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/46484.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/46484.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/46484.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u5168\u65b0 Ubuntu \u670d\u52a1\u5668\u6807\u51c6\u914d\u7f6e\u6307\u5357\uff08docker\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/46484","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=46484"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/46484\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=46484"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=46484"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=46484"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=46484"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}