{"id":1267,"date":"2016-09-20T12:30:54","date_gmt":"2016-09-20T04:30:54","guid":{"rendered":"http:\/\/www.royalwzy.com\/?p=1267"},"modified":"2016-10-24T16:33:52","modified_gmt":"2016-10-24T08:33:52","slug":"docker%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85%e5%8f%8a%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/www.royalwzy.com\/?p=1267","title":{"rendered":"Docker\u73af\u5883\u5b89\u88c5\u53ca\u914d\u7f6e"},"content":{"rendered":"<div>1.\u5b9e\u9a8c\u73af\u5883:<\/div>\n<div>1.1 \u865a\u62df\u673a:VirtualBox 4.3;<\/div>\n<div>1.2 \u64cd\u4f5c\u7cfb\u7edf:CentOS7.2\/3.10.0-327.el7.x86_64;<\/div>\n<div>1.3 \u670d\u52a1\u5668\u540d:docker.htsec.com;<\/div>\n<div>1.4 IP:192.168.10.100(\u5185\u7f51IP)\/10.0.2.15(\u5916\u7f51IP);<\/div>\n<div><\/div>\n<div>2.\u4e0b\u8f7ddocker\u7684rpm\u5305,\u5e76\u914d\u7f6eYUM\u6e90:<\/div>\n<div>2.1 \u4e0b\u8f7ddocker\u7684yum\u5305:wget -S -c -r -np -L https:\/\/yum.dockerproject.org\/repo\/main\/centos\/7\/;<\/div>\n<div>2.2 \u4fee\u6539\u76ee\u5f55:<\/div>\n<div>mkdir -p \/tools\/docker\/centos7<\/div>\n<div>mv yum.dockerproject.org\/repo\/main\/centos\/7\/* \/tools\/docker\/centos7\/<\/div>\n<div>2.3 \u6dfb\u52a0\/etc\/yum.repos.d\/docker.repo\u6587\u4ef6,\u914d\u7f6eyum\u6e90;<\/div>\n<div>[dockerrepo]<\/div>\n<div>name=Docker Repository<\/div>\n<div>baseurl=file:\/\/\/tools\/docker\/centos7<\/div>\n<div>enabled=1<\/div>\n<div>gpgcheck=0<\/div>\n<div><\/div>\n<div>3.\u6dfb\u52a0CentOS\u64cd\u4f5c\u7cfb\u7edf\u7684YUM\u6e90:<\/div>\n<div>3.1 \u6302\u8f7d\u5149\u76d8\u5e76\u628a\u5185\u5bb9\u62f7\u8d1d\u81f3\/tools\/centos72\/\u76ee\u5f55;<\/div>\n<div>3.2 \u6dfb\u52a0\/etc\/yum.repos.d\/centos.repo\u6587\u4ef6,\u914d\u7f6eyum\u6e90\uff1b<\/div>\n<div>[centosrepo]<\/div>\n<div>name=CentOS7 Repository<\/div>\n<div>baseurl=file:\/\/\/tools\/centos72\/<\/div>\n<div>enabled=1<\/div>\n<div>gpgcheck=0<\/div>\n<div>3.3 \u521b\u5efayum\u7f13\u5b58:<\/div>\n<div>yum clean all<\/div>\n<div>yum makecache<\/div>\n<div><\/div>\n<div>4.\u5b89\u88c5\u5e76\u542f\u52a8docker:<\/div>\n<div>4.1 \u5fc5\u8981\u6761\u4ef6:Docker\u5fc5\u987b\u5b89\u88c5\u572864\u4f4d\u64cd\u4f5c\u7cfb\u7edf\u4e0a,\u800c\u4e14\u5185\u6838\u7248\u672c\u5fc5\u987b\u5927\u4e8e3.10;(CentOS7\u7684\u5185\u6838\u7248\u672c\u6700\u5c0f\u662f3.10,\u4f7f\u7528uname -r\u547d\u4ee4\u67e5\u770b)<\/div>\n<div>4.2 \u4f7f\u7528yum\u5b89\u88c5:\u5982\u679c\u670d\u52a1\u5668\u53ef\u4ee5\u8bbf\u95ee\u5916\u7f51,\u5219\u53ef\u4ee5\u76f4\u63a5\u914d\u7f6e\u6307\u5411\u5b98\u65b9\u7684YUM\u6e90;n\u5728\u4f01\u4e1a\u5185\u90e8\u4e00\u822c\u4f1a\u6784\u5efa\u79c1\u6709\u7684YUM\u6e90;<\/div>\n<div>yum update -y<\/div>\n<div>yum install -y docker-engine<\/div>\n<div>4.3 \u5982\u679c\u76f4\u63a5\u4f7f\u7528rpm\u5b89\u88c5\u7684\u8bdd,\u9700\u8981\u5148\u89e3\u51b3\u5305\u4f9d\u8d56;<\/div>\n<div>yum -y install libcgroup libtool-ltdl policycoreutils-python<\/div>\n<div>rpm -ivh docker-engine-selinux-1.11.2-1.el7.centos.noarch.rpm<\/div>\n<div>rpm -ivh docker-engine-1.11.2-1.el7.centos.x86_64.rpm<\/div>\n<div>4.4 \u542f\u52a8docker;<\/div>\n<div>service docker start \u6216\u8005 \/bin\/systemctl start\u00a0 docker.service<\/div>\n<div>4.5 \u914d\u7f6e\u5f00\u673a\u542f\u52a8;<\/div>\n<div>chkconfig docker on \u6216\u8005 systemctl enable docker.service<\/div>\n<div><\/div>\n<div>5.\u9a8c\u8bc1docker\u662f\u5426\u5b89\u88c5\u6210\u529f;<\/div>\n<div>[root@docker ~]# docker run hello-world<\/div>\n<div>Unable to find image &#8216;hello-world:latest&#8217; locally<\/div>\n<div>latest: Pulling from library\/hello-world<\/div>\n<div><\/div>\n<div>c04b14da8d14: Pull complete<\/div>\n<div>Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9<\/div>\n<div>Status: Downloaded newer image for hello-world:latest<\/div>\n<div>WARNING: IPv4 forwarding is disabled. Networking will not work.<\/div>\n<div><\/div>\n<div>Hello from Docker!<\/div>\n<div>This message shows that your installation appears to be working correctly.<\/div>\n<div><\/div>\n<div>To generate this message, Docker took the following steps:<\/div>\n<div>\u00a01. The Docker client contacted the Docker daemon.<\/div>\n<div>\u00a02. The Docker daemon pulled the &#8220;hello-world&#8221; image from the Docker Hub.<\/div>\n<div>\u00a03. The Docker daemon created a new container from that image which runs the<\/div>\n<div>\u00a0 \u00a0 executable that produces the output you are currently reading.<\/div>\n<div>\u00a04. The Docker daemon streamed that output to the Docker client, which sent it<\/div>\n<div>\u00a0 \u00a0 to your terminal.<\/div>\n<div><\/div>\n<div>To try something more ambitious, you can run an Ubuntu container with:<\/div>\n<div>\u00a0$ docker run -it ubuntu bash<\/div>\n<div><\/div>\n<div>Share images, automate workflows, and more with a free Docker Hub account:<\/div>\n<div>\u00a0https:\/\/hub.docker.com<\/div>\n<div><\/div>\n<div>For more examples and ideas, visit:<\/div>\n<div>\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/userguide\/\">https:\/\/docs.docker.com\/engine\/userguide\/<\/a><\/div>\n<div><\/div>\n<div><\/div>\n<div><\/div>\n<div>\u95ee\u9898:WARNING: IPv4 forwarding is disabled. Networking will not work.<\/div>\n<div>\u89e3\u51b3\u529e\u6cd5:<\/div>\n<div>1.\u5728\/usr\/lib\/sysctl.d\/00-system.conf\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee3\u7801;<\/div>\n<div>net.ipv4.ip_forward=1<\/div>\n<div>2.\u91cd\u542fnetwork\u670d\u52a1;<\/div>\n<div>systemctl restart network<\/div>\n<div>3.\u67e5\u770b\u662f\u5426\u4fee\u6539\u6210\u529f;<\/div>\n<div>sysctl net.ipv4.ip_forward<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5b9e\u9a8c\u73af\u5883: 1.1 \u865a\u62df\u673a:VirtualBox 4.3; 1.2 \u64cd\u4f5c\u7cfb\u7edf:CentOS7.2\/3.10 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[43],"class_list":["post-1267","post","type-post","status-publish","format-standard","hentry","category-cloud","tag-docker"],"_links":{"self":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/1267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1267"}],"version-history":[{"count":1,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/1267\/revisions"}],"predecessor-version":[{"id":1268,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/1267\/revisions\/1268"}],"wp:attachment":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1267"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}