{"id":472,"date":"2023-07-07T10:25:15","date_gmt":"2023-07-07T02:25:15","guid":{"rendered":"https:\/\/www.wangzheduo.com\/?p=472"},"modified":"2023-07-07T10:31:37","modified_gmt":"2023-07-07T02:31:37","slug":"%e5%ae%89%e8%a3%85docker","status":"publish","type":"post","link":"https:\/\/biji.niaowan.com\/?p=472","title":{"rendered":"\u5b89\u88c5DOCKER"},"content":{"rendered":"<p>\u5f53\u7136\uff0c\u4ee5\u4e0b\u662f\u5728 Debian \u4e0a\u5b89\u88c5 Docker \u5e76\u521b\u5efa\u5bb9\u5668\u62c9\u53d6\u5b98\u65b9 Debian 11 \u955c\u50cf\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u754c\u9762\u3002<\/li>\n<li>\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u5df2\u7ecf\u66f4\u65b0\u5230\u6700\u65b0\u8f6f\u4ef6\u5305\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-sql\">sudo apt <span class=\"hljs-keyword\">update<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u5b89\u88c5\u5fc5\u8981\u7684\u8f6f\u4ef6\u5305\u4ee5\u5141\u8bb8\u4f7f\u7528 HTTPS \u4ed3\u5e93\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs\">sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u6dfb\u52a0 Docker \u5b98\u65b9 GPG \u5bc6\u94a5\u4ee5\u9a8c\u8bc1\u4e0b\u8f7d\u7684\u8f6f\u4ef6\u5305\u7684\u5b8c\u6574\u6027\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u6dfb\u52a0 Docker \u8f6f\u4ef6\u5305\u4ed3\u5e93\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">echo<\/span> <span class=\"hljs-string\">\"deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/debian <span class=\"hljs-subst\">$(lsb_release -cs)<\/span> stable\"<\/span> | sudo <span class=\"hljs-built_in\">tee<\/span> \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\u4ee5\u5305\u542b Docker \u8f6f\u4ef6\u5305\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-sql\">sudo apt <span class=\"hljs-keyword\">update<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u5b89\u88c5 Docker \u5f15\u64ce\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-lua\">sudo apt install docker-ce docker-ce-cli containerd.<span class=\"hljs-built_in\">io<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u9a8c\u8bc1 Docker \u662f\u5426\u6b63\u786e\u5b89\u88c5\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u68c0\u67e5 Docker \u7248\u672c\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-css\">docker <span class=\"hljs-attr\">--version<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u5982\u679c\u60a8\u5e0c\u671b\u5728\u975e root \u7528\u6237\u4e0b\u8fd0\u884c Docker \u547d\u4ee4\uff0c\u53ef\u4ee5\u5c06\u5f53\u524d\u7528\u6237\u6dfb\u52a0\u5230 <code>docker<\/code> \u7528\u6237\u7ec4\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\">sudo usermod -aG docker <span class=\"hljs-variable\">$USER<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<p>\u8bf7\u786e\u4fdd\u5c06 <code>$USER<\/code> \u66ff\u6362\u4e3a\u60a8\u5f53\u524d\u7684\u7528\u6237\u540d\u3002<\/li>\n<li>\u91cd\u65b0\u767b\u5f55\u6216\u6ce8\u9500\u5e76\u518d\u6b21\u767b\u5f55\uff0c\u4ee5\u4f7f\u7528\u6237\u7ec4\u66f4\u6539\u751f\u6548\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bb9\u5668\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3a\u9002\u5408\u60a8\u7684\u9879\u76ee\u7684\u5bb9\u5668\u540d\u79f0\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-lua\">docker <span class=\"hljs-built_in\">create<\/span> <span class=\"hljs-comment\">--name my-debian-container debian:11<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<li>\u542f\u52a8\u5bb9\u5668\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-perl\">docker start <span class=\"hljs-keyword\">my<\/span>-debian-container<br \/>\n<\/code><\/div>\n<\/div>\n<p>\u5bb9\u5668\u5c06\u5f00\u59cb\u8fd0\u884c\u3002<\/li>\n<li>\u8fde\u63a5\u5230\u5bb9\u5668\u7684\u7ec8\u7aef\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-perl\">docker <span class=\"hljs-keyword\">exec<\/span> -it <span class=\"hljs-keyword\">my<\/span>-debian-container bash<br \/>\n<\/code><\/div>\n<\/div>\n<p>\u8fd9\u5c06\u5728\u5bb9\u5668\u4e2d\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\u3002<\/li>\n<li>\u73b0\u5728\uff0c\u60a8\u5df2\u7ecf\u5728\u5bb9\u5668\u4e2d\uff0c\u53ef\u4ee5\u5728\u5176\u4e2d\u6267\u884c\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 <code>apt<\/code> \u5305\u7ba1\u7406\u5668\u5b89\u88c5\u5176\u4ed6\u8f6f\u4ef6\u5305\u3001\u914d\u7f6e\u73af\u5883\u7b49\u3002\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-php-template\"><span class=\"xml\">apt update<br \/>\napt install <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">package_name<\/span>&gt;<\/span><br \/>\n<\/span><\/code><\/div>\n<\/div>\n<p>\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5728\u5bb9\u5668\u4e2d\u8fdb\u884c\u5176\u4ed6\u64cd\u4f5c\u3002<\/li>\n<li>\u9000\u51fa\u5bb9\u5668\u7684\u7ec8\u7aef\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\"><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"!whitespace-pre hljs language-bash\"><span class=\"hljs-built_in\">exit<\/span><br \/>\n<\/code><\/div>\n<\/div>\n<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728 Debian \u4e0a\u5b89\u88c5 Docker \u5e76\u521b\u5efa\u5bb9\u5668\uff0c\u7136\u540e\u62c9\u53d6\u5b98\u65b9 Debian 11 \u955c\u50cf\u7684\u6b65\u9aa4\u3002\u8bf7\u6ce8\u610f\uff0c\u6839\u636e\u60a8\u7684\u7cfb\u7edf\u914d\u7f6e\u548c\u7f51\u7edc\u901f\u5ea6\uff0c\u4e0b\u8f7d\u955c\u50cf\u548c\u5b89\u88c5\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u7136\uff0c\u4ee5\u4e0b\u662f\u5728 Debian \u4e0a\u5b89\u88c5 Docker \u5e76\u521b\u5efa\u5bb9\u5668\u62c9\u53d6\u5b98\u65b9 Debian 11 \u955c\u50cf\u7684\u6b65\u9aa4\uff1a \u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u754c\u9762\u3002 \u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u5df2\u7ecf\u66f4\u65b0\u5230\u6700\u65b0\u8f6f\u4ef6\u5305\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a sudo apt u&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-472","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=\/wp\/v2\/posts\/472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=472"}],"version-history":[{"count":6,"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=\/wp\/v2\/posts\/472\/revisions"}],"predecessor-version":[{"id":478,"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=\/wp\/v2\/posts\/472\/revisions\/478"}],"wp:attachment":[{"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/biji.niaowan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}