{"id":573,"date":"2024-09-15T00:50:22","date_gmt":"2024-09-14T16:50:22","guid":{"rendered":"https:\/\/forelink.top\/?p=573"},"modified":"2024-09-15T00:50:23","modified_gmt":"2024-09-14T16:50:23","slug":"docker%e7%ae%80%e4%bb%8b%e5%92%8c%e5%ae%89%e8%a3%85%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/forelink.top\/index.php\/2024\/09\/15\/docker%e7%ae%80%e4%bb%8b%e5%92%8c%e5%ae%89%e8%a3%85%e6%96%b9%e6%b3%95\/","title":{"rendered":"Docker\u7b80\u4ecb\u548c\u5b89\u88c5\u65b9\u6cd5"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"\u7b80\u4ecb\uff1a\">\u7b80\u4ecb\uff1a<\/h1>\n\n\n\n<p>Docker \u662f\u57fa\u4e8eGo\u8bed\u8a00\u5b9e\u73b0\uff0c\u8f7b\u91cf\u7ea7\uff0c\u53ef\u79fb\u690d\u7684\u5f00\u6e90\u5e94\u7528\u5bb9\u5668\u5f15\u64ce\n\u4f7f\u7528\u6c99\u7bb1\u673a\u5236\u8fd0\u884c\uff0c\u5bb9\u5668\u5f00\u9500\u4f4e\u4e14\u76f8\u4e92\u9694\u79bb<\/p>\n\n\n\n<p>\u53ef\u5728MAC Windows Linux\u4e0a\u5b89\u88c5\u8fd0\u884c<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"linux-docker\u5b89\u88c5\">Linux Docker\u5b89\u88c5<\/h1>\n\n\n\n<p><strong>\u5b98\u7f51\u4e0b\u8f7d\u6587\u6863<\/strong> <a href=\"https:\/\/docs.docker.com\/engine\/install\/debian\/#install-using-the-repository\">Debian | Docker Docs<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"debian\u5b89\u88c5\">Debian\u5b89\u88c5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u914d\u7f6e\u5b98\u65b9apt\u6e90\">\u914d\u7f6e\u5b98\u65b9apt\u6e90<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># Add Docker's official GPG key:\nsudo apt-get update\nsudo apt-get install ca-certificates curl\nsudo install -m 0755 -d \/etc\/apt\/keyrings\nsudo curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg -o \/etc\/apt\/keyrings\/docker.asc\nsudo chmod a+r \/etc\/apt\/keyrings\/docker.asc\n\n# Add the repository to Apt sources:\necho \\\n  \"deb &#91;arch=$(dpkg --print-architecture) signed-by=\/etc\/apt\/keyrings\/docker.asc] https:\/\/download.docker.com\/linux\/debian \\\n  $(. \/etc\/os-release &amp;&amp; echo \"$VERSION_CODENAME\") stable\" | \\\n  sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null\nsudo apt-get update\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u5b89\u88c5-docker\">\u5b89\u88c5 Docker<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\">\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo docker run hello-world\n<\/code><\/pre>\n\n\n\n<p>\u8be5\u547d\u4ee4\u4f1a\u4e0b\u8f7d\u4e00\u4e2a<code>hello-world<\/code>\u6d4b\u8bd5\u955c\u50cf\uff0c\u5e76\u5206\u914d\u4e00\u4e2a\u5bb9\u5668\u8fd0\u884c\u3002\n\u5bb9\u5668\u8fd0\u884c\u540e\uff0c\u5982\u679cdocker\u5b89\u88c5\u6210\u529f\uff0c\u4f1a\u6253\u5370\u51fa\u786e\u8ba4\u4fe1\u606f\uff0c\u968f\u540e\u81ea\u52a8\u9000\u51fa\u3002<\/p>\n\n\n\n<p><img decoding=\"async\" alt=\"image.png\" src=\"https:\/\/forelink-picgo.oss-cn-beijing.aliyuncs.com\/img\/20240914141940.png\">\n\u770b\u5230\u8be5\u4fe1\u606f\uff0c\u8bf4\u660edocker\u670d\u52a1\u6b63\u5e38\uff0c\u5b89\u88c5\u6210\u529f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u8bbe\u7f6edocker\u81ea\u542f\uff08\u53ef\u9009\uff09\">\u8bbe\u7f6eDocker\u81ea\u542f\uff08\u53ef\u9009\uff09<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemlctl enable docker\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u5b89\u88c5-\u672c\u5730debian-deb\u5305\">\u5b89\u88c5 \u672c\u5730Debian Deb\u5305<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get update\nsudo apt-get install .\/docker-desktop-&lt;arch&gt;.deb\n<\/code><\/pre>\n\n\n\n<p>Docker Desktop \u9ed8\u8ba4\u5b89\u88c5\u5728 \/opt\/docker-desktop \u4e2d<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u914d\u7f6e-docker\u914d\u7f6e\u6587\u4ef6\">\u914d\u7f6e Docker\u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"debian-\u684c\u9762\u7248\u5b89\u88c5\">Debian \u684c\u9762\u7248\u5b89\u88c5<\/h2>\n\n\n\n<p>\u5728Debian \u4e0a\u63a8\u8350\u5b89\u88c5\u4f7f\u7528Docker Desktop\u3002<\/p>\n\n\n\n<p><img decoding=\"async\" alt=\"image.png\" src=\"https:\/\/forelink-picgo.oss-cn-beijing.aliyuncs.com\/img\/20240914114513.png\">\n\u53f3\u952e\u590d\u5236\u94fe\u63a5 \u4f7f\u7528 wget\u547d\u4ee4\u4e0b\u8f7d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/desktop.docker.com\/linux\/main\/amd64\/docker-desktop-amd64.deb\n<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u955c\u50cf\u548c\u5bb9\u5668\">\u955c\u50cf\u548c\u5bb9\u5668<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u955c\u50cf\">\u955c\u50cf<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\u67e5\u770b\u955c\u50cf\n    docker image &#91;-q]\n    &#91;-q] \u8fd4\u56de\u6240\u6709\u955c\u50cf\u7684\u6807\u8bc6\u7b26\/ID\n    REPOSITORY \u955c\u50cf\u540d\n    TAG \u7248\u672c\u53f7\n    IMAGE ID \u6807\u8bc6\u7b26\n    CREATED \u521b\u5efa\u65f6\u95f4\n    SIZE \u955c\u50cf\u5927\u5c0f\n\n\u641c\u7d22\u955c\u50cf\uff08\u9700\u8054\u7f51\uff09\n    docker search &#91;something]\n\n\u62c9\u53d6\u955c\u50cf\uff08\u9ed8\u8ba4\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\uff09\n    docker pull &#91;\u4e0b\u8f7d\u5185\u5bb9:\u7248\u672c\u53f7]\n    \u5728docker.hub\u53ef\u4ee5\u67e5\u627eimage\u7684\u4fe1\u606f\n\n\u5220\u9664\u955c\u50cf\n    docker rmi &#91;image id\/\u955c\u50cf\u540d]\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u5bb9\u5668\">\u5bb9\u5668<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\u8fd0\u884c\u5bb9\u5668\n    docker run &#91;options] &#91;\u955c\u50cf\u540d:\u7248\u672c\u53f7] &#91;COMMANDS] &#91;\u5176\u4ed6\u53c2\u6570]\n    options\uff1a\n        -i \u4fdd\u6301\u5bb9\u5668\u8fd0\u884c\n        -t \u80fd\u7ed9\u5bb9\u5668\u5206\u914d\u4e00\u4e2a\u7ec8\u7aef\uff0c\u63a5\u53d7\u540e\u7eed\u7684\u547d\u4ee4\uff08\u901a\u5e38\u4e0e-i\u540c\u65f6\u4f7f\u7528\uff09\n        -d \u4ee5\u5b88\u62a4\u6a21\u5f0f\u8fd0\u884c\u5bb9\u5668\uff0c\u521b\u5efa\u4e00\u4e2a\u540e\u53f0\u5bb9\u5668\uff0c\u9000\u51fa\u540e\u5bb9\u5668\u4e0d\u4f1a\u81ea\u52a8\u5173\u95ed\n        -i -t -d\u53ef\u4ee5\u5408\u5e76\u4e3a -dit\n        -p \u7aef\u53e3\u6620\u5c04 \u5c06\u5bb9\u5668\u7684\u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u7684\u7aef\u53e3\n            \u683c\u5f0f\u4e3a -p \u5bbf\u4e3b\u673a\u7aef\u53e3:\u5bb9\u5668\u7aef\u53e3\n        -v \u5377\u6302\u8f7d\uff0c\u5c06\u5bbf\u4e3b\u673a\u7684\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u7684\u76ee\u5f55\n            \u683c\u5f0f\u4e3a -v \/\u5bbf\u4e3b\u673a\/\u76ee\u5f55:\/\u5bb9\u5668\/\u76ee\u5f55\n        -e \u73af\u5883\u53d8\u91cf \u8bbe\u7f6e\u5bb9\u5668\u5185\u90e8\u4f7f\u7528\u7684\u73af\u5883\u53d8\u91cf\n            \u683c\u5f0f\u4e3a -e \"MY_VAR=my_value\" \u5e38\u7528\u4e8e\u7cfb\u7edf\u5bb9\u5668\u4e2d\n        --rm \u81ea\u52a8\u5220\u9664 \u5bb9\u5668\u505c\u6b62\u540e\u81ea\u52a8\u5220\u9664\uff0c\u91ca\u653e\u8d44\u6e90\u3002\n        --name\u80fd\u7ed9\u5bb9\u5668\u6307\u5b9a\u4e00\u4e2a\u522b\u540d\n            \u6307\u5b9a\u8fd0\u884c\u7cfb\u7edf\u7248\u672c\n            \u8fd0\u884c\u540e\u80fd\u8fdb\u5165\u5bb9\u5668\u5185\u90e8\u8fdb\u884c\u64cd\u4f5c\n            exit\u9000\u51fa\u540e\u5bb9\u5668\u4f1a\u88ab\u5173\u95ed\n        \u8fd8\u6709\u5176\u4ed6\u542f\u52a8\u9009\u9879\uff0c\u4e0d\u4e00\u4e00\u5217\u51fa\n    \uff08\u4ee5\u4e0b\u4e3a\u53ef\u9009\uff09\n    COMMANDS:\n        \u5bb9\u5668\u542f\u52a8\u65f6\u8c03\u7528\u7684\u547d\u4ee4\u3002\n        \u5982\u679c\u8fd0\u884c\u4e00\u4e2a ubuntu \u5bb9\u5668\uff0c\u9ed8\u8ba4\u547d\u4ee4\u662f\/bin\/bash\n        \u4f1a\u8fdb\u5165\u4e00\u4e2a\u4ea4\u4e92\u5f0f Bash shell\n    \u5176\u4ed6\u53c2\u6570 \u662f\u4f20\u9012\u7ed9\u547d\u4ee4\u7684\u53c2\u6570\n    \n\u8fdb\u5165\u5bb9\u5668\u5185\u90e8\n    docker exec &#91;options] &#91;\u5bb9\u5668\u522b\u540dname]\n\n\u67e5\u770b\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\n    docker ps &#91;options]\n    \u67e5\u770b\u5bb9\u5668\u7684\u521b\u5efa\u547d\u4ee4\n    -a \u67e5\u770b\u6240\u6709\u521b\u5efa\u8fc7\u7684\u5bb9\u5668\n    -q \u8fd4\u56de\u5bb9\u5668\u7684\u8bc6\u522b\u53f7\n\n\u542f\u52a8\u5bb9\u5668\n    docker start &#91;\u5bb9\u5668\u522b\u540d]\n\u5173\u95ed\u5bb9\u5668\n    docker stop &#91;\u5bb9\u5668\u522b\u540d]\n\u5220\u9664\u5bb9\u5668\n    docker rm &#91;\u5bb9\u5668\u522b\u540d]\n    \u4e0d\u80fd\u5220\u9664\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\n\n\u67e5\u770b\u5bb9\u5668\u4fe1\u606f\n    docker inspect &#91;\u5bb9\u5668\u522b\u540d]\n\n\u590d\u5408\u547d\u4ee4\n    docker rm `docker ps -aq`\n    \u5220\u9664\u6240\u6709\u5bb9\u5668\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb\uff1a Docker \u662f\u57fa\u4e8eGo\u8bed\u8a00\u5b9e\u73b0\uff0c\u8f7b\u91cf\u7ea7\uff0c\u53ef\u79fb\u690d\u7684\u5f00\u6e90\u5e94\u7528\u5bb9\u5668\u5f15\u64ce \u4f7f\u7528\u6c99\u7bb1\u673a\u5236\u8fd0\u884c\uff0c\u5bb9\u5668\u5f00\u9500\u4f4e\u4e14\u76f8\u4e92 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[49,17],"tags":[],"class_list":["post-573","post","type-post","status-publish","format-standard","hentry","category-docker","category-17"],"_links":{"self":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts\/573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/comments?post=573"}],"version-history":[{"count":1,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts\/573\/revisions"}],"predecessor-version":[{"id":574,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/posts\/573\/revisions\/574"}],"wp:attachment":[{"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/media?parent=573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/categories?post=573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/forelink.top\/index.php\/wp-json\/wp\/v2\/tags?post=573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}