{"id":1957,"date":"2021-01-28T09:31:55","date_gmt":"2021-01-28T01:31:55","guid":{"rendered":"https:\/\/www.yusian.com\/blog\/?p=1957"},"modified":"2021-01-28T09:51:58","modified_gmt":"2021-01-28T01:51:58","slug":"docker%e7%9a%84%e5%9f%ba%e6%9c%ac%e5%ae%89%e8%a3%85helloworld","status":"publish","type":"post","link":"https:\/\/www.yusian.com\/blog\/devops\/2021\/01\/28\/0931551957.html","title":{"rendered":"Docker\u7684\u57fa\u672c\u5b89\u88c5HelloWorld"},"content":{"rendered":"<h2>1\u3001\u5f15\u64ce\u7684\u5b89\u88c5<\/h2>\n<p>Docker\u5206\u4e3aClient\u4e0eEnginer\u4e24\u7aef\uff0c\u53ef\u4ee5\u7c7b\u6bd4Mysql\uff0c\u4e00\u4e2a\u670d\u52a1\u7aef\u7a0b\u5e8f\u4e00\u4e2a\u63a7\u5236\u53f0\u7a0b\u5e8f<\/p>\n<p>\u4ee5CentOS\u4e3a\u4f8b\uff0cEnginer\u7684\u5b89\u88c5\u5206\u4e3a\u4ee5\u4e0b\u6b65\u9aa4<\/p>\n<ol>\n<li>\u5378\u8f7d\u539f\u6709\u7684\u7248\u672c\uff1a\n<pre><code class=\"language-shell line-numbers\">$ sudo yum remove docker \\\n                 docker-client \\\n                 docker-client-latest \\\n                 docker-common \\\n                 docker-latest \\\n                 docker-latest-logrotate \\\n                 docker-logrotate \\\n                 docker-engine\n<\/code><\/pre>\n<\/li>\n<li>\u8bbe\u7f6eDocker\u4ed3\u5e93\n<pre><code class=\"language-shell line-numbers\">$ sudo yum install -y yum-utils\n# \u4f7f\u7528\u963f\u91cc\u4e91\u56fd\u5185\u955c\u50cf\n$ sudo yum-config-manager \\\n   --add-repo \\\n   https:\/\/mirrors.aliyun.com\/docker-ce\/linux\/centos\/docker-ce.repo\n\n<\/code><\/pre>\n<\/li>\n<li>\u5b89\u88c5Docker\u5f15\u64ce\u3001\u63a7\u5236\u53f0\n<pre><code class=\"language-shell line-numbers\">$ sudo yum install docker-ce docker-ce-cli containerd.io\n<\/code><\/pre>\n<\/li>\n<li>\u542f\u52a8Docker\u670d\u52a1\n<pre><code class=\"language-shell line-numbers\">$ sudo systemctl start docker\n<\/code><\/pre>\n<\/li>\n<li>\u5b89\u88c5\u5b8c\u6bd5\uff0c\u67e5\u770bdocker\u7248\u672c\u53ca\u76f8\u5173\u4fe1\u606f\n<pre><code class=\"language-shell line-numbers\">$ docker version\nClient: Docker Engine - Community\nVersion:           20.10.2\nAPI version:       1.41\nGo version:        go1.13.15\nGit commit:        2291f61\nBuilt:             Mon Dec 28 16:17:40 2020\nOS\/Arch:           linux\/amd64\nContext:           default\nExperimental:      true\n\nServer: Docker Engine - Community\nEngine:\n Version:          20.10.2\n API version:      1.41 (minimum version 1.12)\n Go version:       go1.13.15\n Git commit:       8891c58\n Built:            Mon Dec 28 16:15:09 2020\n OS\/Arch:          linux\/amd64\n Experimental:     false\ncontainerd:\n Version:          1.4.3\n GitCommit:        269548fa27e0089a8b8278fc4fc781d7f65a939b\nrunc:\n Version:          1.0.0-rc92\n GitCommit:        ff819c7e9184c13b7c2607fe6c30ae19403a7aff\ndocker-init:\n Version:          0.19.0\n GitCommit:        de40ad0\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<h2>2\u3001\u955c\u50cf\u4e0b\u8f7d\u4e0e\u5b89\u88c5<\/h2>\n<ol>\n<li>\u5b98\u65b9\u7ed9\u4e86\u4ee5\u4e0b\u56fe\u6765\u8bf4\u660e\u6574\u4e2aDocker\u4f53\u7cfb\uff0c\u5206\u4e3a\u5ba2\u6237\u7aef\u3001\u4e3b\u673a\u3001\u4ed3\u5e93<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/docs.docker.com\/engine\/images\/architecture.svg\" alt=\"Docker Architecture Diagram\" \/><\/p>\n<ul>\n<li>\u5ba2\u6237\u7aef\u7528\u4e8e\u5bf9\u6574\u4e2aDocker\u8fdb\u884c\u64cd\u4f5c\uff0c\u7c7b\u4f3cMysql\u7684\uff0c\u53ef\u4ee5\u662f\u547d\u4ee4\u884c\u7ec8\u7aef\uff0c\u4e5f\u53ef\u4ee5\u662f\u53ef\u89c6\u5316\u754c\u9762\uff1b<\/li>\n<li>\u4e3b\u673a\u7531Docker\u7684\u5b88\u62a4\u8fdb\u7a0b(daemon)\u7edf\u4e00\u7ba1\u7406\uff0c\u7ba1\u7406\u7684\u5bf9\u8c61\u6709\u5bb9\u5668\u3001\u955c\u50cf\u3001\u6216\u4e0e\u5176\u4ed6\u670d\u52a1\u5668\u7684\u5b88\u62a4\u8fdb\u7a0b\u901a\u4fe1\u6216\u534f\u4f5c\uff0c\u955c\u50cf\u4e0e\u5bb9\u5668\u53ef\u4ee5\u7c7b\u6bd4\u4e8e\u7c7b\u4e0e\u5bf9\u8c61\u7684\u5173\u7cfb\uff0c\u901a\u8fc7\u955c\u50cf\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u5bb9\u5668\uff0c\u5bb9\u5668\u662f\u5b9e\u4f8b\uff1b<\/li>\n<li>\u4ed3\u5e93\u4e3b\u8981\u7528\u4e8e\u5b58\u50a8\u955c\u50cf\uff0c\u7c7b\u4f3c\u4e8eGithub\u8fd9\u79cd\u4ee3\u7801\u4ed3\u5e93\uff0c\u601d\u60f3\u662f\u4e00\u6837\u7684\u3002<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>\u5b98\u65b9\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2ahello-world\u7684demo\u955c\u50cf\uff0c\u53ef\u4ee5\u4f53\u9a8c\u4e00\u4e0b\uff1a\n<p><strong>\u641c\u7d22\u4ed3\u5e93\u4e2d\u7684\u955c\u50cf<\/strong><\/p>\n<pre><code class=\"language-shell line-numbers\">$ docker search hello-world\nNAME                                       DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED\nhello-world                                Hello World! (an example of minimal Dockeriz\u2026   1371      [OK]       \nkitematic\/hello-world-nginx                A light-weight nginx container that demonstr\u2026   148                  \ntutum\/hello-world                          Image to test docker deployments. Has Apache\u2026   77                   [OK]\ndockercloud\/hello-world                    Hello World!                                    19                   [OK]\ncrccheck\/hello-world                       Hello World web server in under 2.5 MB          14                   [OK]\nvad1mo\/hello-world-rest                    A simple REST Service that echoes back all t\u2026   4                    [OK]\nppc64le\/hello-world                        Hello World! (an example of minimal Dockeriz\u2026   2                    \nansibleplaybookbundle\/hello-world-db-apb   An APB which deploys a sample Hello World! a\u2026   1                    [OK]\nansibleplaybookbundle\/hello-world-apb      An APB which deploys a sample Hello World! a\u2026   1                    [OK]\nmarkmnei\/hello-world-java-docker           Hello-World-Java-docker                         1                    [OK]\nsouravpatnaik\/hello-world-go               hello-world in Golang                           1                    \nrancher\/hello-world                                                                        1                    \ndatawire\/hello-world                       Hello World! Simple Hello World implementati\u2026   1                    [OK]\nstrimzi\/hello-world-consumer                                                               0                    \nstrimzi\/hello-world-streams                                                                0                    \nkoudaiii\/hello-world                                                                       0                    \nstrimzi\/hello-world-producer                                                               0                    \nburdz\/hello-world-k8s                      To provide a simple webserver that can have \u2026   0                    [OK]\nbusinessgeeks00\/hello-world-nodejs                                                         0                    \nfreddiedevops\/hello-world-spring-boot                                                      0                    \ninfrastructureascode\/hello-world           A tiny \"Hello World\" web server with a healt\u2026   0                    [OK]\nairwavetechio\/hello-world                                                                  0                    \nkevindockercompany\/hello-world                                                             0                    \nnirmata\/hello-world                                                                        0                    [OK]\nokteto\/hello-world  \n<\/code><\/pre>\n<p><strong>\u62c9\u53d6\u955c\u50cf\u5230\u672c\u5730\uff0c\u7c7b\u4f3cgit\u7684pull\u64cd\u4f5c<\/strong><\/p>\n<pre><code class=\"language-shell line-numbers\">$ docker pull hello-world\nUsing default tag: latest\nlatest: Pulling from library\/hello-world\n0e03bdcc26d7: Pull complete \nDigest: sha256:31b9c7d48790f0d8c50ab433d9c3b7e17666d6993084c002c2ff1ca09b96391d\nStatus: Downloaded newer image for hello-world:latest\ndocker.io\/library\/hello-world:latest\n<\/code><\/pre>\n<p><strong>\u542f\u52a8\u955c\u50cf<\/strong><\/p>\n<pre><code class=\"language-shell line-numbers\">$ docker run hello-world\n\nHello from Docker!\nThis message shows that your installation appears to be working correctly.\n\nTo generate this message, Docker took the following steps:\n1. The Docker client contacted the Docker daemon.\n2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\n   (amd64)\n3. The Docker daemon created a new container from that image which runs the\n   executable that produces the output you are currently reading.\n4. The Docker daemon streamed that output to the Docker client, which sent it\n   to your terminal.\n\nTo try something more ambitious, you can run an Ubuntu container with:\n$ docker run -it ubuntu bash\n\nShare images, automate workflows, and more with a free Docker ID:\nhttps:\/\/hub.docker.com\/\n\nFor more examples and ideas, visit:\nhttps:\/\/docs.docker.com\/get-started\/\n<\/code><\/pre>\n<\/li>\n<li>\n<p>\u5230\u6b64\u4e3a\u6b62\uff0cDocker\u7684\u57fa\u672c\u5b89\u88c5\u5c31\u5df2\u5168\u90e8\u7ed3\u675f<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5f15\u64ce\u7684\u5b89\u88c5 Docker\u5206\u4e3aClient\u4e0eEnginer\u4e24\u7aef\uff0c\u53ef\u4ee5\u7c7b\u6bd4Mysql\uff0c\u4e00\u4e2a\u670d\u52a1\u7aef\u7a0b\u5e8f\u4e00\u4e2a\u63a7\u5236\u53f0\u7a0b\u5e8f \u4ee5CentOS\u4e3a\u4f8b\uff0cEnginer\u7684\u5b89\u88c5\u5206\u4e3a\u4ee5\u4e0b\u6b65\u9aa4 \u5378\u8f7d\u539f\u6709\u7684\u7248\u672c\uff1a $ sudo yum remove docker \\ docker-client \\ docker-client-latest \\ docker-common \\ docker-latest \\ docker-latest-logrotate \\ docker-logrotate \\ docker-engine \u8bbe\u7f6eDocker\u4ed3\u5e93 $ sudo yum install -y yum-utils # \u4f7f\u7528\u963f\u91cc\u4e91\u56fd\u5185\u955c\u50cf $ sudo yum-config-manager \\ &#8211;add-repo \\ https:\/\/mirrors.aliyun.com\/docker-ce\/linux\/centos\/docker-ce.repo \u5b89\u88c5Docker\u5f15\u64ce\u3001\u63a7\u5236\u53f0 $ sudo yum install docker-ce docker-ce-cli containerd.io \u542f\u52a8Docker\u670d\u52a1 $ sudo systemctl start docker \u5b89\u88c5\u5b8c\u6bd5\uff0c\u67e5\u770bdocker\u7248\u672c\u53ca\u76f8\u5173\u4fe1\u606f $ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[345],"tags":[346],"class_list":["post-1957","post","type-post","status-publish","format-standard","hentry","category-devops","tag-docker"],"_links":{"self":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/comments?post=1957"}],"version-history":[{"count":0,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/posts\/1957\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/media?parent=1957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/categories?post=1957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yusian.com\/blog\/wp-json\/wp\/v2\/tags?post=1957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}