{"id":657,"date":"2025-12-04T09:18:42","date_gmt":"2025-12-04T01:18:42","guid":{"rendered":"https:\/\/www.kz-hub.tech\/?p=657"},"modified":"2025-12-04T09:18:58","modified_gmt":"2025-12-04T01:18:58","slug":"ubantu-%e7%b3%bb%e7%bb%9f%e4%b8%8a-docker-%e7%9a%84%e5%ae%89%e8%a3%85","status":"publish","type":"post","link":"https:\/\/www.kz-hub.tech\/index.php\/2025\/12\/04\/ubantu-%e7%b3%bb%e7%bb%9f%e4%b8%8a-docker-%e7%9a%84%e5%ae%89%e8%a3%85\/","title":{"rendered":"Ubantu \u7cfb\u7edf\u4e0a Docker \u7684\u5b89\u88c5"},"content":{"rendered":"<p>\u5b98\u7f51\u94fe\u63a5\uff1a<a href=\"https:\/\/docs.docker.com\/engine\/install\/ubuntu\/\">https:\/\/docs.docker.com\/engine\/install\/ubuntu\/<\/a><\/p>\n<h1>1. \u5b89\u88c5<\/h1>\n<p>\u672c\u6d41\u7a0b\u9700\u4f7f\u7528apt\u5b89\u88c5\uff0c\u5148\u66f4\u65b0apt\u53ca\u5176\u8d44\u6e90\uff1a<\/p>\n<pre><code class=\"language-bash\"># Add Docker&#039;s official GPG key:\nsudo apt update\nsudo apt install ca-certificates curl\nsudo install -m 0755 -d \/etc\/apt\/keyrings\nsudo curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg -o \/etc\/apt\/keyrings\/docker.asc\nsudo chmod a+r \/etc\/apt\/keyrings\/docker.asc\n\n# Add the repository to Apt sources:\nsudo tee \/etc\/apt\/sources.list.d\/docker.sources &lt;&lt;EOF\nTypes: deb\nURIs: https:\/\/download.docker.com\/linux\/ubuntu\nSuites: $(. \/etc\/os-release &amp;&amp; echo &quot;${UBUNTU_CODENAME:-$VERSION_CODENAME}&quot;)\nComponents: stable\nSigned-By: \/etc\/apt\/keyrings\/docker.asc\nEOF\n\nsudo apt update<\/code><\/pre>\n<p>\u5b89\u88c5\u6700\u65b0\u7248\u672cDocker\uff1a<\/p>\n<pre><code>sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<\/code><\/pre>\n<p>\u67e5\u770bDocker\u72b6\u6001:<\/p>\n<pre><code class=\"language-bash\">sudo systemctl status docker<\/code><\/pre>\n<p>\u5982\u672a\u542f\u52a8\uff0c\u542f\u52a8Docker\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo systemctl start docker<\/code><\/pre>\n<h1>2. \u4e0b\u8f7d\u5bb9\u5668<\/h1>\n<pre><code>docker pull ubuntu<\/code><\/pre>\n<p>\u67e5\u770b\u4e0b\u8f7d\u7684\u5bb9\u5668\uff1a<\/p>\n<pre><code>docker images<\/code><\/pre>\n<h1>3. \u542f\u52a8\u5bb9\u5668<\/h1>\n<h2>3.1 \u542f\u52a8\u4e00\u4e2a\u5bb9\u5668\u5e76\u8fdb\u5165\u5176\u4ea4\u4e92\u5f0f\u7ec8\u7aef<\/h2>\n<pre><code>docker run -it ubuntu \/bin\/bash<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u5bb9\u5668\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528 -d \u53c2\u6570\uff1a<\/p>\n<pre><code>docker run -d ubuntu<\/code><\/pre>\n<p>\u67e5\u770b\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\uff0c\u53ef\u6dfb\u52a0-a\u6765\u67e5\u770b\u6240\u6709\u5bb9\u5668\uff08\u5305\u62ec\u505c\u6b62\u7684\u5bb9\u5668\uff09\uff0c\u6765\u67e5\u627e\u5bb9\u5668id:<\/p>\n<pre><code>docker ps -a<\/code><\/pre>\n<p>\u901a\u8fc7\u5bb9\u5668id\u8fdb\u5165\u4e00\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668<\/p>\n<pre><code>docker exec -it container_id \/bin\/bash<\/code><\/pre>\n<p>\u505c\u6b62\u4e00\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\uff1a<\/p>\n<pre><code>docker stop container_id<\/code><\/pre>\n<p>\u5220\u9664\u5bb9\u5668<\/p>\n<pre><code>docker rm container_id<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b98\u7f51\u94fe\u63a5\uff1ahttps:\/\/docs.docker.com\/engine\/install\/ubuntu\/ 1. &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-657","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/comments?post=657"}],"version-history":[{"count":2,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/657\/revisions"}],"predecessor-version":[{"id":659,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/posts\/657\/revisions\/659"}],"wp:attachment":[{"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/media?parent=657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/categories?post=657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kz-hub.tech\/index.php\/wp-json\/wp\/v2\/tags?post=657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}