{"id":379,"date":"2018-03-14T10:18:29","date_gmt":"2018-03-14T02:18:29","guid":{"rendered":"http:\/\/www.max-shu.com\/blog\/?p=379"},"modified":"2018-03-14T10:18:29","modified_gmt":"2018-03-14T02:18:29","slug":"docker-%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e5%ae%9e%e8%b7%b5%ef%bc%88%e5%ae%8c%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.max-shu.com\/blog\/?p=379","title":{"rendered":"Docker \u2014\u2014 \u4ece\u5165\u95e8\u5230\u5b9e\u8df5\uff08\u5b8c\uff09"},"content":{"rendered":"<div>\n<h1>10. \u5b9e\u6218\u6848\u4f8b<\/h1>\n<p>\u4ecb\u7ecd\u4e00\u4e9b\u5178\u578b\u7684\u5e94\u7528\u573a\u666f\u548c\u6848\u4f8b\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>10.1. \u4f7f\u7528 Supervisor \u6765\u7ba1\u7406\u8fdb\u7a0b<\/h2>\n<p>Docker \u5bb9\u5668\u5728\u542f\u52a8\u7684\u65f6\u5019\u5f00\u542f\u5355\u4e2a\u8fdb\u7a0b\uff0c\u6bd4\u5982\uff0c\u4e00\u4e2a ssh \u6216\u8005 apache \u7684 daemon \u670d\u52a1\u3002\u4f46\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u5728\u4e00\u4e2a\u673a\u5668\u4e0a\u5f00\u542f\u591a\u4e2a\u670d\u52a1\uff0c\u8fd9\u53ef\u4ee5\u6709\u5f88\u591a\u65b9\u6cd5\uff0c\u6700\u7b80\u5355\u7684\u5c31\u662f\u628a\u591a\u4e2a\u542f\u52a8\u547d\u4ee4\u65b9\u5230\u4e00\u4e2a\u542f\u52a8\u811a\u672c\u91cc\u9762\uff0c\u542f\u52a8\u7684\u65f6\u5019\u76f4\u63a5\u542f\u52a8\u8fd9\u4e2a\u811a\u672c\uff0c\u53e6\u5916\u5c31\u662f\u5b89\u88c5\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<p>\u672c\u5c0f\u8282\u5c06\u4f7f\u7528\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177 supervisor \u6765\u7ba1\u7406\u5bb9\u5668\u4e2d\u7684\u591a\u4e2a\u8fdb\u7a0b\u3002\u4f7f\u7528 Supervisor \u53ef\u4ee5\u66f4\u597d\u7684\u63a7\u5236\u3001\u7ba1\u7406\u3001\u91cd\u542f\u6211\u4eec\u5e0c\u671b\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u6f14\u793a\u4e00\u4e0b\u5982\u4f55\u540c\u65f6\u4f7f\u7528 ssh \u548c apache \u670d\u52a1\u3002<\/p>\n<h3>\u914d\u7f6e<\/h3>\n<p>\u9996\u5148\u521b\u5efa\u4e00\u4e2a Dockerfile\uff0c\u5185\u5bb9\u548c\u5404\u90e8\u5206\u7684\u89e3\u91ca\u5982\u4e0b\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;FROM ubuntu:13.04\r\nMAINTAINER examples@docker.com\r\nRUN echo \"deb http:\/\/archive.ubuntu.com\/ubuntu precise main universe\" &gt; \/etc\/apt\/sources.list\r\nRUN apt-get update\r\nRUN apt-get upgrade -y\r\n<wbr \/>de&gt;<\/pre>\n<h3>\u5b89\u88c5 supervisor<\/h3>\n<p>\u5b89\u88c5 ssh\u3001apache \u548c supervisor\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;RUN apt-get install -y openssh-server apache2 supervisor\r\nRUN mkdir -p \/var\/run\/sshd\r\nRUN mkdir -p \/var\/log\/supervisor\r\n<wbr \/>de&gt;<\/pre>\n<p>\u8fd9\u91cc\u5b89\u88c5 3 \u4e2a\u8f6f\u4ef6\uff0c\u8fd8\u521b\u5efa\u4e86 2 \u4e2a ssh \u548c supervisor \u670d\u52a1\u6b63\u5e38\u8fd0\u884c\u6240\u9700\u8981\u7684\u76ee\u5f55\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;COPY supervisord.conf \/etc\/supervisor\/conf.d\/supervisord.conf\r\n<wbr \/>de&gt;<\/pre>\n<p>\u6dfb\u52a0 supervisord \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u590d\u5236\u914d\u7f6e\u6587\u4ef6\u5230\u5bf9\u5e94\u76ee\u5f55\u4e0b\u9762\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;EXPOSE 22 80\r\nCMD [\"\/usr\/bin\/supervisord\"]\r\n<wbr \/>de&gt;<\/pre>\n<p>\u8fd9\u91cc\u6211\u4eec\u6620\u5c04\u4e86 22 \u548c 80 \u7aef\u53e3\uff0c\u4f7f\u7528 supervisord \u7684\u53ef\u6267\u884c\u8def\u5f84\u542f\u52a8\u670d\u52a1\u3002<\/p>\n<h3>supervisor\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9<\/h3>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;[supervisord]\r\nnodaemon=true\r\n[program:sshd]\r\ncommand=\/usr\/sbin\/sshd -D\r\n\r\n[program:apache2]\r\ncommand=\/bin\/bash -c \"source \/etc\/apache2\/envvars &amp;&amp; exec \/usr\/sbin\/apache2 -DFOREGROUND\"\r\n<wbr \/>de&gt;<\/pre>\n<p>\u914d\u7f6e\u6587\u4ef6\u5305\u542b\u76ee\u5f55\u548c\u8fdb\u7a0b\uff0c\u7b2c\u4e00\u6bb5 supervsord \u914d\u7f6e\u8f6f\u4ef6\u672c\u8eab\uff0c\u4f7f\u7528 nodaemon \u53c2\u6570\u6765\u8fd0\u884c\u3002\u7b2c\u4e8c\u6bb5\u5305\u542b\u8981\u63a7\u5236\u7684 2 \u4e2a\u670d\u52a1\u3002\u6bcf\u4e00\u6bb5\u5305\u542b\u4e00\u4e2a\u670d\u52a1\u7684\u76ee\u5f55\u548c\u542f\u52a8\u8fd9\u4e2a\u670d\u52a1\u7684\u547d\u4ee4\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u521b\u5efa\u955c\u50cf\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker build -t test\/supervisord .\r\n<wbr \/>de&gt;<\/pre>\n<p>\u542f\u52a8 supervisor \u5bb9\u5668\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run -p 22 -p 80 -t -i test\/supervisords\r\n2013-11-25 18:53:22,312 CRIT Supervisor running as root (no user in config file)\r\n2013-11-25 18:53:22,312 WARN Included extra file \"\/etc\/supervisor\/conf.d\/supervisord.conf\" during parsing\r\n2013-11-25 18:53:22,342 INFO supervisord started with pid 1\r\n2013-11-25 18:53:23,346 INFO spawned: 'sshd' with pid 6\r\n2013-11-25 18:53:23,349 INFO spawned: 'apache2' with pid 7\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker run<wbr \/>de&gt;\u00a0\u6765\u542f\u52a8\u6211\u4eec\u521b\u5efa\u7684\u5bb9\u5668\u3002\u4f7f\u7528\u591a\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-p<wbr \/>de&gt;\u00a0\u6765\u6620\u5c04\u591a\u4e2a\u7aef\u53e3\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u80fd\u540c\u65f6\u8bbf\u95ee ssh \u548c apache \u670d\u52a1\u4e86\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u65b9\u6cd5\u521b\u5efa\u4e00\u4e2a\u53ea\u6709 ssh \u670d\u52a1\u7684\u57fa\u7840\u955c\u50cf\uff0c\u4e4b\u540e\u521b\u5efa\u955c\u50cf\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u955c\u50cf\u4e3a\u57fa\u7840\u6765\u521b\u5efa<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>10.2. \u521b\u5efa tomcat\/weblogic \u96c6\u7fa4<\/h2>\n<h3>\u5b89\u88c5 tomcat \u955c\u50cf<\/h3>\n<p>\u51c6\u5907\u597d\u9700\u8981\u7684 jdk\u3001tomcat \u7b49\u8f6f\u4ef6\u653e\u5230 home \u76ee\u5f55\u4e0b\u9762\uff0c\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker run -t -i -v \/home:\/opt\/da<wbr \/>ta  --name mk_tomcat ubuntu \/bin\/bash\r\n<wbr \/>de&gt;<\/pre>\n<p>\u8fd9\u6761\u547d\u4ee4\u6302\u8f7d\u672c\u5730 home \u76ee\u5f55\u5230\u5bb9\u5668\u7684 \/opt\/da<wbr \/>ta \u76ee\u5f55\uff0c\u5bb9\u5668\u5185\u76ee\u5f55\u82e5\u4e0d\u5b58\u5728\uff0c\u5219\u4f1a\u81ea\u52a8\u521b\u5efa\u3002\u63a5\u4e0b\u6765\u5c31\u662f tomcat \u7684\u57fa\u672c\u914d\u7f6e\uff0cjdk \u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u597d\u4e4b\u540e\uff0c\u5c06 tomcat \u7a0b\u5e8f\u653e\u5230 \/opt\/apache-tomcat \u4e0b\u9762 \u7f16\u8f91 \/etc\/supervisor\/conf.d\/supervisor.conf \u6587\u4ef6\uff0c\u6dfb\u52a0 tomcat \u9879<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;[supervisord]\r\nnodaemon=true\r\n\r\n[program:tomcat]\r\ncommand=\/opt\/apache-tomcat\/bin\/startup.sh\r\n\r\n[program:sshd]\r\ncommand=\/usr\/sbin\/sshd -D\r\ndocker commit  ac6474aeb31d  tomcat\r\n<wbr \/>de&gt;<\/pre>\n<p>\u65b0\u5efa tomcat \u6587\u4ef6\u5939\uff0c\u65b0\u5efa Dockerfile\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;FROM mk_tomcat\r\nEXPOSE  22 8080\r\nCMD [\"\/usr\/bin\/supervisord\"]\r\n<wbr \/>de&gt;<\/pre>\n<p>\u6839\u636e Dockerfile \u521b\u5efa\u955c\u50cf\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker build tomcat tomcat\r\n<wbr \/>de&gt;<\/pre>\n<h3>\u5b89\u88c5 weblogic \u955c\u50cf<\/h3>\n<p>\u6b65\u9aa4\u548c tomcat \u57fa\u672c\u4e00\u81f4\uff0c\u8fd9\u91cc\u8d34\u4e00\u4e0b\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;supervisor.conf\r\n[supervisord]\r\nnodaemon=true\r\n\r\n\r\n[program:weblogic]\r\ncommand=\/opt\/Middleware\/user_projects\/domains\/base_domain\/bin\/startWebLogic.sh\r\n\r\n[program:sshd]\r\ncommand=\/usr\/sbin\/sshd -D\r\ndockerfile\r\nFROM weblogic\r\nEXPOSE  22 7001\r\nCMD [\"\/usr\/bin\/supervisord\"]\r\n<wbr \/>de&gt;<\/pre>\n<h3>tomcat\/weblogic \u955c\u50cf\u7684\u4f7f\u7528<\/h3>\n<h4>\u5b58\u50a8\u7684\u4f7f\u7528<\/h4>\n<p>\u5728\u542f\u52a8\u7684\u65f6\u5019\uff0c\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-v<wbr \/>de&gt;\u00a0\u53c2\u6570<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;-v, --volume=[]            Bind mount a volume (e.g. from the host: -v \/host:\/container, from docker: -v \/container)\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5c06\u672c\u5730\u78c1\u76d8\u6620\u5c04\u5230\u5bb9\u5668\u5185\u90e8\uff0c\u5b83\u5728\u4e3b\u673a\u548c\u5bb9\u5668\u4e4b\u95f4\u662f\u5b9e\u65f6\u53d8\u5316\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u66f4\u65b0\u7a0b\u5e8f\u3001\u4e0a\u4f20\u4ee3\u7801\u53ea\u9700\u8981\u66f4\u65b0\u7269\u7406\u4e3b\u673a\u7684\u76ee\u5f55\u5c31\u53ef\u4ee5\u4e86<\/p>\n<h4>tomcat \u548c weblogic \u96c6\u7fa4\u7684\u5b9e\u73b0<\/h4>\n<p>tomcat \u53ea\u8981\u5f00\u542f\u591a\u4e2a\u5bb9\u5668\u5373\u53ef<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker run -d -v -p 204:22 -p 7003:8080 -v \/home\/da<wbr \/>ta:\/opt\/da<wbr \/>ta --name tm1 tomcat \/usr\/bin\/supervisord\r\ndocker run -d -v -p 205:22 -p 7004:8080 -v \/home\/da<wbr \/>ta:\/opt\/da<wbr \/>ta --name tm2 tomcat \/usr\/bin\/supervisord\r\ndocker run -d -v -p 206:22 -p 7005:8080 -v \/home\/da<wbr \/>ta:\/opt\/da<wbr \/>ta --name tm3 tomcat \/usr\/bin\/supervisord\r\n<wbr \/>de&gt;<\/pre>\n<p>\u8fd9\u91cc\u8bf4\u4e00\u4e0b weblogic \u7684\u914d\u7f6e\uff0c\u5927\u5bb6\u77e5\u9053 weblogic \u6709\u4e00\u4e2a\u57df\u7684\u6982\u5ff5\u3002\u5982\u679c\u8981\u4f7f\u7528\u5e38\u89c4\u7684 administrator +node \u7684\u65b9\u5f0f\u90e8\u7f72\uff0c\u5c31\u9700\u8981\u5728 supervisord \u4e2d\u5206\u522b\u5199\u51fa administartor server \u548c node server \u7684\u542f\u52a8\u811a\u672c\uff0c\u8fd9\u6837\u505a\u7684\u4f18\u70b9\u662f\uff1a<\/p>\n<ul>\n<li>\u53ef\u4ee5\u4f7f\u7528 weblogic \u7684\u96c6\u7fa4\uff0c\u540c\u6b65\u7b49\u6982\u5ff5<\/li>\n<li>\u90e8\u7f72\u4e00\u4e2a\u96c6\u7fa4\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ea\u9700\u8981\u5b89\u88c5\u4e00\u6b21\u5e94\u7528\u5230\u96c6\u7fa4\u4e0a\u5373\u53ef<\/li>\n<\/ul>\n<p>\u7f3a\u70b9\u662f\uff1a<\/p>\n<ul>\n<li>Docker \u914d\u7f6e\u590d\u6742\u4e86<\/li>\n<li>\u6ca1\u529e\u6cd5\u81ea\u52a8\u6269\u5c55\u96c6\u7fa4\u7684\u8ba1\u7b97\u5bb9\u91cf\uff0c\u5982\u9700\u6dfb\u52a0\u8282\u70b9\uff0c\u9700\u8981\u5728 administrator \u4e0a\u5148\u521b\u5efa\u8282\u70b9\uff0c\u7136\u540e\u518d\u914d\u7f6e\u65b0\u7684\u5bb9\u5668 supervisor \u542f\u52a8\u811a\u672c\uff0c\u7136\u540e\u518d\u542f\u52a8\u5bb9\u5668 \u53e6\u5916\u79cd\u65b9\u6cd5\u662f\u5c06\u6240\u6709\u7684\u7a0b\u5e8f\u90fd\u5b89\u88c5\u5728 adminiserver \u4e0a\u9762\uff0c\u9700\u8981\u6269\u5c55\u7684\u65f6\u5019\uff0c\u542f\u52a8\u591a\u4e2a\u8282\u70b9\u5373\u53ef\uff0c\u5b83\u7684\u4f18\u70b9\u548c\u7f3a\u70b9\u548c\u4e0a\u4e00\u79cd\u65b9\u6cd5\u6070\u6070\u76f8\u53cd\u3002\uff08\u5efa\u8bae\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\u6765\u90e8\u7f72\u5f00\u53d1\u548c\u6d4b\u8bd5\u73af\u5883\uff09\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker run -d -v -p 204:22 -p 7001:7001 -v \/home\/da<wbr \/>ta:\/opt\/da<wbr \/>ta --name node1 weblogic \/usr\/bin\/supervisord\r\ndocker run -d -v -p 205:22 -p 7002:7001 -v \/home\/da<wbr \/>ta:\/opt\/da<wbr \/>ta --name node2 weblogic \/usr\/bin\/supervisord\r\ndocker run -d -v -p 206:22 -p 7003:7001 -v \/home\/da<wbr \/>ta:\/opt\/da<wbr \/>ta --name node3 weblogic \/usr\/bin\/supervisord\r\n<wbr \/>de&gt;<\/pre>\n<\/li>\n<\/ul>\n<p>\u8fd9\u6837\u5728\u524d\u7aef\u4f7f\u7528 nginx \u6765\u505a\u8d1f\u8f7d\u5747\u8861\u5c31\u53ef\u4ee5\u5b8c\u6210\u914d\u7f6e\u4e86<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>10.3. \u591a\u53f0\u7269\u7406\u4e3b\u673a\u4e4b\u95f4\u7684\u5bb9\u5668\u4e92\u8054\uff08\u66b4\u9732\u5bb9\u5668\u5230\u771f\u5b9e\u7f51\u7edc\u4e2d\uff09<\/h2>\n<p>Docker \u9ed8\u8ba4\u7684\u6865\u63a5\u7f51\u5361\u662f docker0\u3002\u5b83\u53ea\u4f1a\u5728\u672c\u673a\u6865\u63a5\u6240\u6709\u7684\u5bb9\u5668\u7f51\u5361\uff0c\u4e3e\u4f8b\u6765\u8bf4\u5bb9\u5668\u7684\u865a\u62df\u7f51\u5361\u5728\u4e3b\u673a\u4e0a\u770b\u4e00\u822c\u53eb\u505a veth<em>*<\/em>\u00a0\u800c Docker \u53ea\u662f\u628a\u6240\u6709\u8fd9\u4e9b\u7f51\u5361\u6865\u63a5\u5728\u4e00\u8d77\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;[root@opnvz ~]# brctl show\r\nbridge name     bridge id               STP enabled     interfaces\r\ndocker0         8000.56847afe9799       no              veth0889\r\n                                             veth3c7b\r\n                                             veth4061\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5728\u5bb9\u5668\u4e2d\u770b\u5230\u7684\u5730\u5740\u4e00\u822c\u662f\u50cf\u4e0b\u9762\u8fd9\u6837\u7684\u5730\u5740\uff1a<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;root@ac6474aeb31d:~# ip a\r\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UNKNOWN group default\r\n    link\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\r\n    inet 127.0.0.1\/8 scope host lo\r\n       valid_lft forever preferred_lft forever\r\n    inet6 ::1\/128 scope host\r\n       valid_lft forever preferred_lft forever\r\n11: eth0: &lt;BROADCAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP group default qlen 1000\r\n    link\/ether 4a:7d:68:da:09:cf brd ff:ff:ff:ff:ff:ff\r\n    inet 172.17.0.3\/16 scope global eth0\r\n       valid_lft forever preferred_lft forever\r\n    inet6 fe80::487d:68ff:feda:9cf\/64 scope link\r\n       valid_lft forever preferred_lft forever\r\n<wbr \/>de&gt;<\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u628a\u8fd9\u4e2a\u7f51\u7edc\u770b\u6210\u662f\u4e00\u4e2a\u79c1\u6709\u7684\u7f51\u7edc\uff0c\u901a\u8fc7 nat \u8fde\u63a5\u5916\u7f51\uff0c\u5982\u679c\u8981\u8ba9\u5916\u7f51\u8fde\u63a5\u5230\u5bb9\u5668\u4e2d\uff0c\u5c31\u9700\u8981\u505a\u7aef\u53e3\u6620\u5c04\uff0c\u5373 -p \u53c2\u6570\u3002<\/p>\n<p>\u5982\u679c\u5728\u4f01\u4e1a\u5185\u90e8\u5e94\u7528\uff0c\u6216\u8005\u505a\u591a\u4e2a\u7269\u7406\u4e3b\u673a\u7684\u96c6\u7fa4\uff0c\u53ef\u80fd\u9700\u8981\u5c06\u591a\u4e2a\u7269\u7406\u4e3b\u673a\u7684\u5bb9\u5668\u7ec4\u5230\u4e00\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u6765\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u5c06\u8fd9\u4e2a\u7f51\u6865\u6865\u63a5\u5230\u6211\u4eec\u6307\u5b9a\u7684\u7f51\u5361\u4e0a\u3002<\/p>\n<h3>\u62d3\u6251\u56fe<\/h3>\n<p>\u4e3b\u673a A \u548c\u4e3b\u673a B \u7684\u7f51\u5361\u4e00\u90fd\u8fde\u7740\u7269\u7406\u4ea4\u6362\u673a\u7684\u540c\u4e00\u4e2a vlan 101,\u8fd9\u6837\u7f51\u6865\u4e00\u548c\u7f51\u6865\u4e09\u5c31\u76f8\u5f53\u4e8e\u5728\u540c\u4e00\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u4e86\uff0c\u800c\u5bb9\u5668\u4e00\u3001\u5bb9\u5668\u4e09\u3001\u5bb9\u5668\u56db\u4e5f\u5728\u540c\u4e00\u7269\u7406\u7f51\u7edc\u4e2d\u4e86\uff0c\u4ed6\u4eec\u4e4b\u95f4\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\uff0c\u800c\u4e14\u53ef\u4ee5\u8ddf\u540c\u4e00 vlan \u4e2d\u7684\u5176\u4ed6\u7269\u7406\u673a\u5668\u4e92\u8054\u3002<\/p>\n<h3>ubuntu \u793a\u4f8b<\/h3>\n<p>\u4e0b\u9762\u4ee5 ubuntu \u4e3a\u4f8b\u521b\u5efa\u591a\u4e2a\u4e3b\u673a\u7684\u5bb9\u5668\u8054\u7f51: \u521b\u5efa\u81ea\u5df1\u7684\u7f51\u6865,\u7f16\u8f91 \/etc\/network\/interface \u6587\u4ef6<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;auto br0\r\niface br0 inet static\r\naddress 192.168.7.31\r\nnetmask 255.255.240.0\r\ngateway 192.168.7.254\r\nbridge_ports em1\r\nbridge_stp off\r\ndns-nameservers 8.8.8.8 192.168.6.1\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5c06 Docker \u7684\u9ed8\u8ba4\u7f51\u6865\u7ed1\u5b9a\u5230\u8fd9\u4e2a\u65b0\u5efa\u7684 br0 \u4e0a\u9762\uff0c\u8fd9\u6837\u5c31\u5c06\u8fd9\u53f0\u673a\u5668\u4e0a\u5bb9\u5668\u7ed1\u5b9a\u5230 em1 \u8fd9\u4e2a\u7f51\u5361\u6240\u5bf9\u5e94\u7684\u7269\u7406\u7f51\u7edc\u4e0a\u4e86\u3002<\/p>\n<p>ubuntu \u4fee\u6539 \/etc\/default\/docker \u6587\u4ef6\uff0c\u6dfb\u52a0\u6700\u540e\u4e00\u884c\u5185\u5bb9<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;# Docker Upstart and SysVinit configuration file\r\n# Customize location of Docker binary (especially for development testing).\r\n#DOCKER=\"\/usr\/local\/bin\/docker\"\r\n# Use DOCKER_OPTS to modify the daemon startup options.\r\n#DOCKER_OPTS=\"--dns 8.8.8.8 --dns 8.8.4.4\"\r\n\r\n# If you need Docker to use an HTTP proxy, it can also be specified here.\r\n#export http_proxy=\"http:\/\/127.0.0.1:3128\/\"\r\n\r\n# This is also a handy place to tweak where Docker's temporary files go.\r\n#export TMPDIR=\"\/mnt\/bigdrive\/docker-tmp\"\r\n\r\nDOCKER_OPTS=\"-b=br0\"\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5728\u542f\u52a8 Docker \u7684\u65f6\u5019 \u4f7f\u7528 -b \u53c2\u6570 \u5c06\u5bb9\u5668\u7ed1\u5b9a\u5230\u7269\u7406\u7f51\u7edc\u4e0a\u3002\u91cd\u542f Docker \u670d\u52a1\u540e\uff0c\u518d\u8fdb\u5165\u5bb9\u5668\u53ef\u4ee5\u770b\u5230\u5b83\u5df2\u7ecf\u7ed1\u5b9a\u5230\u4f60\u7684\u7269\u7406\u7f51\u7edc\u4e0a\u4e86\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;root@ubuntudocker:~# docker ps\r\nCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                        NAMES\r\n58b043aa05eb        desk_hz:v1          \"\/startup.sh\"       5 days ago          Up 2 seconds        5900\/tcp, 6080\/tcp, 22\/tcp   yanlx\r\nroot@ubuntudocker:~# brctl show\r\nbridge name     bridge id               STP enabled     interfaces\r\nbr0             8000.7e6e617c8d53       no              em1\r\n                                            vethe6e5\r\n<wbr \/>de&gt;<\/pre>\n<p>\u8fd9\u6837\u5c31\u76f4\u63a5\u628a\u5bb9\u5668\u66b4\u9732\u5230\u7269\u7406\u7f51\u7edc\u4e0a\u4e86\uff0c\u591a\u53f0\u7269\u7406\u4e3b\u673a\u7684\u5bb9\u5668\u4e5f\u53ef\u4ee5\u76f8\u4e92\u8054\u7f51\u4e86\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u6837\u5c31\u9700\u8981\u81ea\u5df1\u6765\u4fdd\u8bc1\u5bb9\u5668\u7684\u7f51\u7edc\u5b89\u5168\u4e86\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>10.4. \u6807\u51c6\u5316\u5f00\u53d1\u6d4b\u8bd5\u548c\u751f\u4ea7\u73af\u5883<\/h2>\n<p>\u5bf9\u4e8e\u5927\u90e8\u5206\u4f01\u4e1a\u6765\u8bf4\uff0c\u642d\u5efa PaaS \u65e2\u6ca1\u6709\u90a3\u4e2a\u7cbe\u529b\uff0c\u4e5f\u6ca1\u90a3\u4e2a\u5fc5\u8981\uff0c\u7528 Docker \u505a\u4e2a\u4eba\u7684 sandbox \u7528\u5904\u53c8\u5c0f\u4e86\u70b9\u3002<\/p>\n<p>\u53ef\u4ee5\u7528 Docker \u6765\u6807\u51c6\u5316\u5f00\u53d1\u3001\u6d4b\u8bd5\u3001\u751f\u4ea7\u73af\u5883\u3002<\/p>\n<p>Docker \u5360\u7528\u8d44\u6e90\u5c0f\uff0c\u5728\u4e00\u53f0 E5 128 G \u5185\u5b58\u7684\u670d\u52a1\u5668\u4e0a\u90e8\u7f72 100 \u4e2a\u5bb9\u5668\u90fd\u7ef0\u7ef0\u6709\u4f59\uff0c\u53ef\u4ee5\u5355\u72ec\u62bd\u4e00\u4e2a\u5bb9\u5668\u6216\u8005\u76f4\u63a5\u5728\u5bbf\u4e3b\u7269\u7406\u4e3b\u673a\u4e0a\u90e8\u7f72 samba\uff0c\u5229\u7528 samba \u7684 home \u5206\u4eab\u65b9\u6848\u5c06\u6bcf\u4e2a\u7528\u6237\u7684 home \u76ee\u5f55\u6620\u5c04\u5230\u5f00\u53d1\u4e2d\u5fc3\u548c\u6d4b\u8bd5\u90e8\u95e8\u7684 Windows \u673a\u5668\u4e0a\u3002<\/p>\n<p>\u9488\u5bf9\u67d0\u4e2a\u9879\u76ee\u7ec4\uff0c\u7531\u67b6\u6784\u5e08\u642d\u5efa\u597d\u4e00\u4e2a\u6807\u51c6\u7684\u5bb9\u5668\u73af\u5883\u4f9b\u9879\u76ee\u7ec4\u548c\u6d4b\u8bd5\u90e8\u95e8\u4f7f\u7528\uff0c\u6bcf\u4e2a\u5f00\u53d1\u5de5\u7a0b\u5e08\u53ef\u4ee5\u62e5\u6709\u81ea\u5df1\u5355\u72ec\u7684\u5bb9\u5668\uff0c\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker run -v<wbr \/>de&gt;\u00a0\u5c06\u7528\u6237\u7684 home \u76ee\u5f55\u6620\u5c04\u5230\u5bb9\u5668\u4e2d\u3002\u9700\u8981\u63d0\u4ea4\u6d4b\u8bd5\u65f6\uff0c\u53ea\u9700\u8981\u5c06\u4ee3\u7801\u79fb\u4ea4\u7ed9\u6d4b\u8bd5\u90e8\u95e8\uff0c\u7136\u540e\u5206\u914d\u4e00\u4e2a\u5bb9\u5668\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-v<wbr \/>de&gt;\u00a0\u52a0\u8f7d\u6d4b\u8bd5\u90e8\u95e8\u7684 home \u76ee\u5f55\u542f\u52a8\u5373\u53ef\u3002\u8fd9\u6837\uff0c\u5728\u516c\u53f8\u5185\u90e8\u7684\u5f00\u53d1\u3001\u6d4b\u8bd5\u57fa\u672c\u5c31\u7edf\u4e00\u4e86\uff0c\u4e0d\u4f1a\u51fa\u73b0\u5f00\u53d1\u90e8\u95e8\u63d0\u4ea4\u7684\u4ee3\u7801\uff0c\u6d4b\u8bd5\u90e8\u95e8\u90e8\u7f72\u4e0d\u4e86\u7684\u95ee\u9898\u3002<\/p>\n<p>\u6d4b\u8bd5\u90e8\u95e8\u53d1\u5e03\u6d4b\u8bd5\u901a\u8fc7\u7684\u62a5\u544a\u540e\uff0c\u67b6\u6784\u5e08\u518d\u4e00\u6b21\u68c0\u6d4b\u5bb9\u5668\u73af\u5883\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u4ea4\u7531\u90e8\u7f72\u5de5\u7a0b\u5e08\u5c06\u4ee3\u7801\u548c\u5bb9\u5668\u5206\u522b\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u4e2d\u4e86\u3002\u8fd9\u79cd\u65b9\u5f0f\u7684\u90e8\u7f72\u6a2a\u5411\u6027\u80fd\u7684\u6269\u5c55\u6027\u4e5f\u6781\u597d\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h1>11. \u5b89\u5168<\/h1>\n<p>\u8bc4\u4f30 Docker \u7684\u5b89\u5168\u6027\u65f6\uff0c\u4e3b\u8981\u8003\u8651\u4e09\u4e2a\u65b9\u9762:<\/p>\n<ul>\n<li>\u7531\u5185\u6838\u7684\u540d\u5b57\u7a7a\u95f4\u548c\u63a7\u5236\u7ec4\u673a\u5236\u63d0\u4f9b\u7684\u5bb9\u5668\u5185\u5728\u5b89\u5168<\/li>\n<li>Docker\u7a0b\u5e8f\uff08\u7279\u522b\u662f\u670d\u52a1\u7aef\uff09\u672c\u8eab\u7684\u6297\u653b\u51fb\u6027<\/li>\n<li>\u5185\u6838\u5b89\u5168\u6027\u7684\u52a0\u5f3a\u673a\u5236\u5bf9\u5bb9\u5668\u5b89\u5168\u6027\u7684\u5f71\u54cd<\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>11.1. \u5185\u6838\u540d\u5b57\u7a7a\u95f4<\/h2>\n<p>Docker \u5bb9\u5668\u548c LXC \u5bb9\u5668\u5f88\u76f8\u4f3c\uff0c\u6240\u63d0\u4f9b\u7684\u5b89\u5168\u7279\u6027\u4e5f\u5dee\u4e0d\u591a\u3002\u5f53\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker run<wbr \/>de&gt;\u00a0\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668\u65f6\uff0c\u5728\u540e\u53f0 Docker \u4e3a\u5bb9\u5668\u521b\u5efa\u4e86\u4e00\u4e2a\u72ec\u7acb\u7684\u540d\u5b57\u7a7a\u95f4\u548c\u63a7\u5236\u7ec4\u96c6\u5408\u3002<\/p>\n<p>\u540d\u5b57\u7a7a\u95f4\u63d0\u4f9b\u4e86\u6700\u57fa\u7840\u4e5f\u662f\u6700\u76f4\u63a5\u7684\u9694\u79bb\uff0c\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u7684\u8fdb\u7a0b\u4e0d\u4f1a\u88ab\u8fd0\u884c\u5728\u4e3b\u673a\u4e0a\u7684\u8fdb\u7a0b\u548c\u5176\u5b83\u5bb9\u5668\u53d1\u73b0\u548c\u4f5c\u7528\u3002<\/p>\n<p>\u6bcf\u4e2a\u5bb9\u5668\u90fd\u6709\u81ea\u5df1\u72ec\u6709\u7684\u7f51\u7edc\u6808\uff0c\u610f\u5473\u7740\u5b83\u4eec\u4e0d\u80fd\u8bbf\u95ee\u5176\u4ed6\u5bb9\u5668\u7684 sockets \u6216\u63a5\u53e3\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u4e3b\u673a\u7cfb\u7edf\u4e0a\u505a\u4e86\u76f8\u5e94\u7684\u8bbe\u7f6e\uff0c\u5bb9\u5668\u53ef\u4ee5\u50cf\u8ddf\u4e3b\u673a\u4ea4\u4e92\u4e00\u6837\u7684\u548c\u5176\u4ed6\u5bb9\u5668\u4ea4\u4e92\u3002\u5f53\u6307\u5b9a\u516c\u5171\u7aef\u53e3\u6216\u4f7f\u7528 links \u6765\u8fde\u63a5 2 \u4e2a\u5bb9\u5668\u65f6\uff0c\u5bb9\u5668\u5c31\u53ef\u4ee5\u76f8\u4e92\u901a\u4fe1\u4e86\uff08\u53ef\u4ee5\u6839\u636e\u914d\u7f6e\u6765\u9650\u5236\u901a\u4fe1\u7684\u7b56\u7565\uff09\u3002<\/p>\n<p>\u4ece\u7f51\u7edc\u67b6\u6784\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u6240\u6709\u7684\u5bb9\u5668\u901a\u8fc7\u672c\u5730\u4e3b\u673a\u7684\u7f51\u6865\u63a5\u53e3\u76f8\u4e92\u901a\u4fe1\uff0c\u5c31\u50cf\u7269\u7406\u673a\u5668\u901a\u8fc7\u7269\u7406\u4ea4\u6362\u673a\u901a\u4fe1\u4e00\u6837\u3002<\/p>\n<p>\u90a3\u4e48\uff0c\u5185\u6838\u4e2d\u5b9e\u73b0\u540d\u5b57\u7a7a\u95f4\u548c\u79c1\u6709\u7f51\u7edc\u7684\u4ee3\u7801\u662f\u5426\u8db3\u591f\u6210\u719f\uff1f<\/p>\n<p>\u5185\u6838\u540d\u5b57\u7a7a\u95f4\u4ece 2.6.15 \u7248\u672c\uff082008 \u5e74 7 \u6708\u53d1\u5e03\uff09\u4e4b\u540e\u88ab\u5f15\u5165\uff0c\u6570\u5e74\u95f4\uff0c\u8fd9\u4e9b\u673a\u5236\u7684\u53ef\u9760\u6027\u5728\u8bf8\u591a\u5927\u578b\u751f\u4ea7\u7cfb\u7edf\u4e2d\u88ab\u5b9e\u8df5\u9a8c\u8bc1\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u540d\u5b57\u7a7a\u95f4\u7684\u60f3\u6cd5\u548c\u8bbe\u8ba1\u63d0\u51fa\u7684\u65f6\u95f4\u8981\u66f4\u65e9\uff0c\u6700\u521d\u662f\u4e3a\u4e86\u5728\u5185\u6838\u4e2d\u5f15\u5165\u4e00\u79cd\u673a\u5236\u6765\u5b9e\u73b0\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/OpenVZ\" target=\"_blank\" rel=\"nofollow noopener\">OpenVZ<\/a>\u00a0\u7684\u7279\u6027\u3002 \u800c OpenVZ \u9879\u76ee\u65e9\u5728 2005 \u5e74\u5c31\u53d1\u5e03\u4e86\uff0c\u5176\u8bbe\u8ba1\u548c\u5b9e\u73b0\u90fd\u5df2\u7ecf\u5341\u5206\u6210\u719f\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>11.2. \u63a7\u5236\u7ec4<\/h2>\n<p>\u63a7\u5236\u7ec4\u662f Linux \u5bb9\u5668\u673a\u5236\u7684\u53e6\u5916\u4e00\u4e2a\u5173\u952e\u7ec4\u4ef6\uff0c\u8d1f\u8d23\u5b9e\u73b0\u8d44\u6e90\u7684\u5ba1\u8ba1\u548c\u9650\u5236\u3002<\/p>\n<p>\u5b83\u63d0\u4f9b\u4e86\u5f88\u591a\u6709\u7528\u7684\u7279\u6027\uff1b\u4ee5\u53ca\u786e\u4fdd\u5404\u4e2a\u5bb9\u5668\u53ef\u4ee5\u516c\u5e73\u5730\u5206\u4eab\u4e3b\u673a\u7684\u5185\u5b58\u3001CPU\u3001\u78c1\u76d8 IO \u7b49\u8d44\u6e90\uff1b\u5f53\u7136\uff0c\u66f4\u91cd\u8981\u7684\u662f\uff0c\u63a7\u5236\u7ec4\u786e\u4fdd\u4e86\u5f53\u5bb9\u5668\u5185\u7684\u8d44\u6e90\u4f7f\u7528\u4ea7\u751f\u538b\u529b\u65f6\u4e0d\u4f1a\u8fde\u7d2f\u4e3b\u673a\u7cfb\u7edf\u3002<\/p>\n<p>\u5c3d\u7ba1\u63a7\u5236\u7ec4\u4e0d\u8d1f\u8d23\u9694\u79bb\u5bb9\u5668\u4e4b\u95f4\u76f8\u4e92\u8bbf\u95ee\u3001\u5904\u7406\u6570\u636e\u548c\u8fdb\u7a0b\uff0c\u5b83\u5728\u9632\u6b62\u62d2\u7edd\u670d\u52a1\uff08DDOS\uff09\u653b\u51fb\u65b9\u9762\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002\u5c24\u5176\u662f\u5728\u591a\u7528\u6237\u7684\u5e73\u53f0\uff08\u6bd4\u5982\u516c\u6709\u6216\u79c1\u6709\u7684 PaaS\uff09\u4e0a\uff0c\u63a7\u5236\u7ec4\u5341\u5206\u91cd\u8981\u3002\u4f8b\u5982\uff0c\u5f53\u67d0\u4e9b\u5e94\u7528\u7a0b\u5e8f\u8868\u73b0\u5f02\u5e38\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u4fdd\u8bc1\u4e00\u81f4\u5730\u6b63\u5e38\u8fd0\u884c\u548c\u6027\u80fd\u3002<\/p>\n<p>\u63a7\u5236\u7ec4\u673a\u5236\u59cb\u4e8e 2006 \u5e74\uff0c\u5185\u6838\u4ece 2.6.24 \u7248\u672c\u5f00\u59cb\u88ab\u5f15\u5165\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>11.3. Docker\u670d\u52a1\u7aef\u7684\u9632\u62a4<\/h2>\n<p>\u8fd0\u884c\u4e00\u4e2a\u5bb9\u5668\u6216\u5e94\u7528\u7a0b\u5e8f\u7684\u6838\u5fc3\u662f\u901a\u8fc7 Docker \u670d\u52a1\u7aef\u3002Docker \u670d\u52a1\u7684\u8fd0\u884c\u76ee\u524d\u9700\u8981 root \u6743\u9650\uff0c\u56e0\u6b64\u5176\u5b89\u5168\u6027\u5341\u5206\u5173\u952e\u3002<\/p>\n<p>\u9996\u5148\uff0c\u786e\u4fdd\u53ea\u6709\u53ef\u4fe1\u7684\u7528\u6237\u624d\u53ef\u4ee5\u8bbf\u95ee Docker \u670d\u52a1\u3002Docker \u5141\u8bb8\u7528\u6237\u5728\u4e3b\u673a\u548c\u5bb9\u5668\u95f4\u5171\u4eab\u6587\u4ef6\u5939\uff0c\u540c\u65f6\u4e0d\u9700\u8981\u9650\u5236\u5bb9\u5668\u7684\u8bbf\u95ee\u6743\u9650\uff0c\u8fd9\u5c31\u5bb9\u6613\u8ba9\u5bb9\u5668\u7a81\u7834\u8d44\u6e90\u9650\u5236\u3002\u4f8b\u5982\uff0c\u6076\u610f\u7528\u6237\u542f\u52a8\u5bb9\u5668\u7684\u65f6\u5019\u5c06\u4e3b\u673a\u7684\u6839\u76ee\u5f55<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/<wbr \/>de&gt;\u6620\u5c04\u5230\u5bb9\u5668\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/host<wbr \/>de&gt;\u00a0\u76ee\u5f55\u4e2d\uff0c\u90a3\u4e48\u5bb9\u5668\u7406\u8bba\u4e0a\u5c31\u53ef\u4ee5\u5bf9\u4e3b\u673a\u7684\u6587\u4ef6\u7cfb\u7edf\u8fdb\u884c\u4efb\u610f\u4fee\u6539\u4e86\u3002\u8fd9\u542c\u8d77\u6765\u5f88\u75af\u72c2\uff1f\u4f46\u662f\u4e8b\u5b9e\u4e0a\u51e0\u4e4e\u6240\u6709\u865a\u62df\u5316\u7cfb\u7edf\u90fd\u5141\u8bb8\u7c7b\u4f3c\u7684\u8d44\u6e90\u5171\u4eab\uff0c\u800c\u6ca1\u6cd5\u7981\u6b62\u7528\u6237\u5171\u4eab\u4e3b\u673a\u6839\u6587\u4ef6\u7cfb\u7edf\u5230\u865a\u62df\u673a\u7cfb\u7edf\u3002<\/p>\n<p>\u8fd9\u5c06\u4f1a\u9020\u6210\u5f88\u4e25\u91cd\u7684\u5b89\u5168\u540e\u679c\u3002\u56e0\u6b64\uff0c\u5f53\u63d0\u4f9b\u5bb9\u5668\u521b\u5efa\u670d\u52a1\u65f6\uff08\u4f8b\u5982\u901a\u8fc7\u4e00\u4e2a web \u670d\u52a1\u5668\uff09\uff0c\u8981\u66f4\u52a0\u6ce8\u610f\u8fdb\u884c\u53c2\u6570\u7684\u5b89\u5168\u68c0\u67e5\uff0c\u9632\u6b62\u6076\u610f\u7684\u7528\u6237\u7528\u7279\u5b9a\u53c2\u6570\u6765\u521b\u5efa\u4e00\u4e9b\u7834\u574f\u6027\u7684\u5bb9\u5668<\/p>\n<p>\u4e3a\u4e86\u52a0\u5f3a\u5bf9\u670d\u52a1\u7aef\u7684\u4fdd\u62a4\uff0cDocker \u7684 REST API\uff08\u5ba2\u6237\u7aef\u7528\u6765\u8ddf\u670d\u52a1\u7aef\u901a\u4fe1\uff09\u5728 0.5.2 \u4e4b\u540e\u4f7f\u7528\u672c\u5730\u7684 Unix \u5957\u63a5\u5b57\u673a\u5236\u66ff\u4ee3\u4e86\u539f\u5148\u7ed1\u5b9a\u5728 127.0.0.1 \u4e0a\u7684 TCP \u5957\u63a5\u5b57\uff0c\u56e0\u4e3a\u540e\u8005\u5bb9\u6613\u906d\u53d7\u8de8\u7ad9\u811a\u672c\u653b\u51fb\u3002\u73b0\u5728\u7528\u6237\u4f7f\u7528 Unix \u6743\u9650\u68c0\u67e5\u6765\u52a0\u5f3a\u5957\u63a5\u5b57\u7684\u8bbf\u95ee\u5b89\u5168\u3002<\/p>\n<p>\u7528\u6237\u4ecd\u53ef\u4ee5\u5229\u7528 HTTP \u63d0\u4f9b REST API \u8bbf\u95ee\u3002\u5efa\u8bae\u4f7f\u7528\u5b89\u5168\u673a\u5236\uff0c\u786e\u4fdd\u53ea\u6709\u53ef\u4fe1\u7684\u7f51\u7edc\u6216 VPN\uff0c\u6216\u8bc1\u4e66\u4fdd\u62a4\u673a\u5236\uff08\u4f8b\u5982\u53d7\u4fdd\u62a4\u7684 stunnel \u548c ssl \u8ba4\u8bc1\uff09\u4e0b\u7684\u8bbf\u95ee\u53ef\u4ee5\u8fdb\u884c\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528 HTTPS \u548c\u8bc1\u4e66\u6765\u52a0\u5f3a\u4fdd\u62a4\u3002<\/p>\n<p>\u6700\u8fd1\u6539\u8fdb\u7684 Linux \u540d\u5b57\u7a7a\u95f4\u673a\u5236\u5c06\u53ef\u4ee5\u5b9e\u73b0\u4f7f\u7528\u975e root \u7528\u6237\u6765\u8fd0\u884c\u5168\u529f\u80fd\u7684\u5bb9\u5668\u3002\u8fd9\u5c06\u4ece\u6839\u672c\u4e0a\u89e3\u51b3\u4e86\u5bb9\u5668\u548c\u4e3b\u673a\u4e4b\u95f4\u5171\u4eab\u6587\u4ef6\u7cfb\u7edf\u800c\u5f15\u8d77\u7684\u5b89\u5168\u95ee\u9898\u3002<\/p>\n<p>\u7ec8\u6781\u76ee\u6807\u662f\u6539\u8fdb 2 \u4e2a\u91cd\u8981\u7684\u5b89\u5168\u7279\u6027\uff1a<\/p>\n<ul>\n<li>\u5c06\u5bb9\u5668\u7684 root \u7528\u6237\u6620\u5c04\u5230\u672c\u5730\u4e3b\u673a\u4e0a\u7684\u975e root \u7528\u6237\uff0c\u51cf\u8f7b\u5bb9\u5668\u548c\u4e3b\u673a\u4e4b\u95f4\u56e0\u6743\u9650\u63d0\u5347\u800c\u5f15\u8d77\u7684\u5b89\u5168\u95ee\u9898\uff1b<\/li>\n<li>\u5141\u8bb8 Docker \u670d\u52a1\u7aef\u5728\u975e root \u6743\u9650\u4e0b\u8fd0\u884c\uff0c\u5229\u7528\u5b89\u5168\u53ef\u9760\u7684\u5b50\u8fdb\u7a0b\u6765\u4ee3\u7406\u6267\u884c\u9700\u8981\u7279\u6743\u6743\u9650\u7684\u64cd\u4f5c\u3002\u8fd9\u4e9b\u5b50\u8fdb\u7a0b\u5c06\u53ea\u5141\u8bb8\u5728\u9650\u5b9a\u8303\u56f4\u5185\u8fdb\u884c\u64cd\u4f5c\uff0c\u4f8b\u5982\u4ec5\u4ec5\u8d1f\u8d23\u865a\u62df\u7f51\u7edc\u8bbe\u5b9a\u6216\u6587\u4ef6\u7cfb\u7edf\u7ba1\u7406\u3001\u914d\u7f6e\u64cd\u4f5c\u7b49\u3002<\/li>\n<\/ul>\n<p>\u6700\u540e\uff0c\u5efa\u8bae\u91c7\u7528\u4e13\u7528\u7684\u670d\u52a1\u5668\u6765\u8fd0\u884c Docker \u548c\u76f8\u5173\u7684\u7ba1\u7406\u670d\u52a1\uff08\u4f8b\u5982\u7ba1\u7406\u670d\u52a1\u6bd4\u5982 ssh \u76d1\u63a7\u548c\u8fdb\u7a0b\u76d1\u63a7\u3001\u7ba1\u7406\u5de5\u5177 nrpe\u3001collectd \u7b49\uff09\u3002\u5176\u5b83\u7684\u4e1a\u52a1\u670d\u52a1\u90fd\u653e\u5230\u5bb9\u5668\u4e2d\u53bb\u8fd0\u884c\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>11.4. \u5185\u6838\u80fd\u529b\u673a\u5236<\/h2>\n<p>\u80fd\u529b\u673a\u5236\uff08Capability\uff09\u662f Linux \u5185\u6838\u4e00\u4e2a\u5f3a\u5927\u7684\u7279\u6027\uff0c\u53ef\u4ee5\u63d0\u4f9b\u7ec6\u7c92\u5ea6\u7684\u6743\u9650\u8bbf\u95ee\u63a7\u5236\u3002 Linux \u5185\u6838\u81ea 2.2 \u7248\u672c\u8d77\u5c31\u652f\u6301\u80fd\u529b\u673a\u5236\uff0c\u5b83\u5c06\u6743\u9650\u5212\u5206\u4e3a\u66f4\u52a0\u7ec6\u7c92\u5ea6\u7684\u64cd\u4f5c\u80fd\u529b\uff0c\u65e2\u53ef\u4ee5\u4f5c\u7528\u5728\u8fdb\u7a0b\u4e0a\uff0c\u4e5f\u53ef\u4ee5\u4f5c\u7528\u5728\u6587\u4ef6\u4e0a\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u4e00\u4e2a Web \u670d\u52a1\u8fdb\u7a0b\u53ea\u9700\u8981\u7ed1\u5b9a\u4e00\u4e2a\u4f4e\u4e8e 1024 \u7684\u7aef\u53e3\u7684\u6743\u9650\uff0c\u5e76\u4e0d\u9700\u8981 root \u6743\u9650\u3002\u90a3\u4e48\u5b83\u53ea\u9700\u8981\u88ab\u6388\u6743\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;net_bind_service<wbr \/>de&gt;\u00a0\u80fd\u529b\u5373\u53ef\u3002\u6b64\u5916\uff0c\u8fd8\u6709\u5f88\u591a\u5176\u4ed6\u7684\u7c7b\u4f3c\u80fd\u529b\u6765\u907f\u514d\u8fdb\u7a0b\u83b7\u53d6 root \u6743\u9650\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cDocker \u542f\u52a8\u7684\u5bb9\u5668\u88ab\u4e25\u683c\u9650\u5236\u53ea\u5141\u8bb8\u4f7f\u7528\u5185\u6838\u7684\u4e00\u90e8\u5206\u80fd\u529b\u3002<\/p>\n<p>\u4f7f\u7528\u80fd\u529b\u673a\u5236\u5bf9\u52a0\u5f3a Docker \u5bb9\u5668\u7684\u5b89\u5168\u6709\u5f88\u591a\u597d\u5904\u3002\u901a\u5e38\uff0c\u5728\u670d\u52a1\u5668\u4e0a\u4f1a\u8fd0\u884c\u4e00\u5806\u9700\u8981\u7279\u6743\u6743\u9650\u7684\u8fdb\u7a0b\uff0c\u5305\u62ec\u6709 ssh\u3001cron\u3001syslogd\u3001\u786c\u4ef6\u7ba1\u7406\u5de5\u5177\u6a21\u5757\uff08\u4f8b\u5982\u8d1f\u8f7d\u6a21\u5757\uff09\u3001\u7f51\u7edc\u914d\u7f6e\u5de5\u5177\u7b49\u7b49\u3002\u5bb9\u5668\u8ddf\u8fd9\u4e9b\u8fdb\u7a0b\u662f\u4e0d\u540c\u7684\uff0c\u56e0\u4e3a\u51e0\u4e4e\u6240\u6709\u7684\u7279\u6743\u8fdb\u7a0b\u90fd\u7531\u5bb9\u5668\u4ee5\u5916\u7684\u652f\u6301\u7cfb\u7edf\u6765\u8fdb\u884c\u7ba1\u7406\u3002<\/p>\n<ul>\n<li>ssh \u8bbf\u95ee\u88ab\u4e3b\u673a\u4e0assh\u670d\u52a1\u6765\u7ba1\u7406\uff1b<\/li>\n<li>cron \u901a\u5e38\u5e94\u8be5\u4f5c\u4e3a\u7528\u6237\u8fdb\u7a0b\u6267\u884c\uff0c\u6743\u9650\u4ea4\u7ed9\u4f7f\u7528\u5b83\u670d\u52a1\u7684\u5e94\u7528\u6765\u5904\u7406\uff1b<\/li>\n<li>\u65e5\u5fd7\u7cfb\u7edf\u53ef\u7531 Docker \u6216\u7b2c\u4e09\u65b9\u670d\u52a1\u7ba1\u7406\uff1b<\/li>\n<li>\u786c\u4ef6\u7ba1\u7406\u65e0\u5173\u7d27\u8981\uff0c\u5bb9\u5668\u4e2d\u4e5f\u5c31\u65e0\u9700\u6267\u884c udevd \u4ee5\u53ca\u7c7b\u4f3c\u670d\u52a1\uff1b<\/li>\n<li>\u7f51\u7edc\u7ba1\u7406\u4e5f\u90fd\u5728\u4e3b\u673a\u4e0a\u8bbe\u7f6e\uff0c\u9664\u975e\u7279\u6b8a\u9700\u6c42\uff0c\u5bb9\u5668\u4e0d\u9700\u8981\u5bf9\u7f51\u7edc\u8fdb\u884c\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<p>\u4ece\u4e0a\u9762\u7684\u4f8b\u5b50\u53ef\u4ee5\u770b\u51fa\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\uff0c\u5bb9\u5668\u5e76\u4e0d\u9700\u8981\u201c\u771f\u6b63\u7684\u201d root \u6743\u9650\uff0c\u5bb9\u5668\u53ea\u9700\u8981\u5c11\u6570\u7684\u80fd\u529b\u5373\u53ef\u3002\u4e3a\u4e86\u52a0\u5f3a\u5b89\u5168\uff0c\u5bb9\u5668\u53ef\u4ee5\u7981\u7528\u4e00\u4e9b\u6ca1\u5fc5\u8981\u7684\u6743\u9650\u3002<\/p>\n<ul>\n<li>\u5b8c\u5168\u7981\u6b62\u4efb\u4f55 mount \u64cd\u4f5c\uff1b<\/li>\n<li>\u7981\u6b62\u76f4\u63a5\u8bbf\u95ee\u672c\u5730\u4e3b\u673a\u7684\u5957\u63a5\u5b57\uff1b<\/li>\n<li>\u7981\u6b62\u8bbf\u95ee\u4e00\u4e9b\u6587\u4ef6\u7cfb\u7edf\u7684\u64cd\u4f5c\uff0c\u6bd4\u5982\u521b\u5efa\u65b0\u7684\u8bbe\u5907\u3001\u4fee\u6539\u6587\u4ef6\u5c5e\u6027\u7b49\uff1b<\/li>\n<li>\u7981\u6b62\u6a21\u5757\u52a0\u8f7d\u3002<\/li>\n<\/ul>\n<p>\u8fd9\u6837\uff0c\u5c31\u7b97\u653b\u51fb\u8005\u5728\u5bb9\u5668\u4e2d\u53d6\u5f97\u4e86 root \u6743\u9650\uff0c\u4e5f\u4e0d\u80fd\u83b7\u5f97\u672c\u5730\u4e3b\u673a\u7684\u8f83\u9ad8\u6743\u9650\uff0c\u80fd\u8fdb\u884c\u7684\u7834\u574f\u4e5f\u6709\u9650\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cDocker\u91c7\u7528\u00a0<a href=\"https:\/\/github.com\/docker\/docker\/blob\/master\/daemon\/execdriver\/native\/template\/default_template.go\" target=\"_blank\" rel=\"nofollow noopener\">\u767d\u540d\u5355<\/a>\u00a0\u673a\u5236\uff0c\u7981\u7528\u00a0<a href=\"https:\/\/github.com\/docker\/docker\/blob\/master\/daemon\/execdriver\/native\/template\/default_template.go\" target=\"_blank\" rel=\"nofollow noopener\">\u5fc5\u9700\u529f\u80fd<\/a>\u00a0\u4e4b\u5916\u7684\u5176\u5b83\u6743\u9650\u3002 \u5f53\u7136\uff0c\u7528\u6237\u4e5f\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u9700\u6c42\u6765\u4e3a Docker \u5bb9\u5668\u542f\u7528\u989d\u5916\u7684\u6743\u9650\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>11.5. \u5176\u5b83\u5b89\u5168\u7279\u6027<\/h2>\n<p>\u9664\u4e86\u80fd\u529b\u673a\u5236\u4e4b\u5916\uff0c\u8fd8\u53ef\u4ee5\u5229\u7528\u4e00\u4e9b\u73b0\u6709\u7684\u5b89\u5168\u673a\u5236\u6765\u589e\u5f3a\u4f7f\u7528 Docker \u7684\u5b89\u5168\u6027\uff0c\u4f8b\u5982 TOMOYO, AppArmor, SELinux, GRSEC \u7b49\u3002<\/p>\n<p>Docker \u5f53\u524d\u9ed8\u8ba4\u53ea\u542f\u7528\u4e86\u80fd\u529b\u673a\u5236\u3002\u7528\u6237\u53ef\u4ee5\u91c7\u7528\u591a\u79cd\u65b9\u6848\u6765\u52a0\u5f3a Docker \u4e3b\u673a\u7684\u5b89\u5168\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u5728\u5185\u6838\u4e2d\u542f\u7528 GRSEC \u548c PAX\uff0c\u8fd9\u5c06\u589e\u52a0\u5f88\u591a\u7f16\u8bd1\u548c\u8fd0\u884c\u65f6\u7684\u5b89\u5168\u68c0\u67e5\uff1b\u901a\u8fc7\u5730\u5740\u968f\u673a\u5316\u907f\u514d\u6076\u610f\u63a2\u6d4b\u7b49\u3002\u5e76\u4e14\uff0c\u542f\u7528\u8be5\u7279\u6027\u4e0d\u9700\u8981 Docker \u8fdb\u884c\u4efb\u4f55\u914d\u7f6e\u3002<\/li>\n<li>\u4f7f\u7528\u4e00\u4e9b\u6709\u589e\u5f3a\u5b89\u5168\u7279\u6027\u7684\u5bb9\u5668\u6a21\u677f\uff0c\u6bd4\u5982\u5e26 AppArmor \u7684\u6a21\u677f\u548c Redhat \u5e26 SELinux \u7b56\u7565\u7684\u6a21\u677f\u3002\u8fd9\u4e9b\u6a21\u677f\u63d0\u4f9b\u4e86\u989d\u5916\u7684\u5b89\u5168\u7279\u6027\u3002<\/li>\n<li>\u7528\u6237\u53ef\u4ee5\u81ea\u5b9a\u4e49\u8bbf\u95ee\u63a7\u5236\u673a\u5236\u6765\u5b9a\u5236\u5b89\u5168\u7b56\u7565\u3002<\/li>\n<\/ul>\n<p>\u8ddf\u5176\u5b83\u6dfb\u52a0\u5230 Docker \u5bb9\u5668\u7684\u7b2c\u4e09\u65b9\u5de5\u5177\u4e00\u6837\uff08\u6bd4\u5982\u7f51\u7edc\u62d3\u6251\u548c\u6587\u4ef6\u7cfb\u7edf\u5171\u4eab\uff09\uff0c\u6709\u5f88\u591a\u7c7b\u4f3c\u7684\u673a\u5236\uff0c\u5728\u4e0d\u6539\u53d8 Docker \u5185\u6838\u60c5\u51b5\u4e0b\u5c31\u53ef\u4ee5\u52a0\u56fa\u73b0\u6709\u7684\u5bb9\u5668\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>11.6. \u603b\u7ed3<\/h2>\n<p>\u603b\u4f53\u6765\u770b\uff0cDocker \u5bb9\u5668\u8fd8\u662f\u5341\u5206\u5b89\u5168\u7684\uff0c\u7279\u522b\u662f\u5728\u5bb9\u5668\u5185\u4e0d\u4f7f\u7528 root \u6743\u9650\u6765\u8fd0\u884c\u8fdb\u7a0b\u7684\u8bdd\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u73b0\u6709\u5de5\u5177\uff0c\u6bd4\u5982 Apparmor, SELinux, GRSEC \u6765\u589e\u5f3a\u5b89\u5168\u6027\uff1b\u751a\u81f3\u81ea\u5df1\u5728\u5185\u6838\u4e2d\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u5b89\u5168\u673a\u5236\u3002<\/p>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<h1>12. Dockerfile<\/h1>\n<p>\u4f7f\u7528 Dockerfile \u53ef\u4ee5\u5141\u8bb8\u7528\u6237\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u955c\u50cf\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>12.1. \u57fa\u672c\u7ed3\u6784<\/h2>\n<p>Dockerfile \u7531\u4e00\u884c\u884c\u547d\u4ee4\u8bed\u53e5\u7ec4\u6210\uff0c\u5e76\u4e14\u652f\u6301\u4ee5\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;#<wbr \/>de&gt;\u00a0\u5f00\u5934\u7684\u6ce8\u91ca\u884c\u3002<\/p>\n<p>\u4e00\u822c\u7684\uff0cDockerfile \u5206\u4e3a\u56db\u90e8\u5206\uff1a\u57fa\u7840\u955c\u50cf\u4fe1\u606f\u3001\u7ef4\u62a4\u8005\u4fe1\u606f\u3001\u955c\u50cf\u64cd\u4f5c\u6307\u4ee4\u548c\u5bb9\u5668\u542f\u52a8\u65f6\u6267\u884c\u6307\u4ee4\u3002<\/p>\n<p>\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;# This dockerfile uses the ubuntu image\r\n# VERSION 2 - EDITION 1\r\n# Author: docker_user\r\n# Command format: Instruction [arguments \/ command] ..\r\n\r\n# Base image to use, this must be set as the first line\r\nFROM ubuntu\r\n\r\n# Maintainer: docker_user &lt;docker_user at email.com&gt; (@docker_user)\r\nMAINTAINER docker_user docker_user@email.com\r\n\r\n# Commands to update the image\r\nRUN echo \"deb http:\/\/archive.ubuntu.com\/ubuntu\/ raring main universe\" &gt;&gt; \/etc\/apt\/sources.list\r\nRUN apt-get update &amp;&amp; apt-get install -y nginx\r\nRUN echo \"\\ndaemon off;\" &gt;&gt; \/etc\/nginx\/nginx.conf\r\n\r\n# Commands when creating a new container\r\nCMD \/usr\/sbin\/nginx\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5176\u4e2d\uff0c\u4e00\u5f00\u59cb\u5fc5\u987b\u6307\u660e\u6240\u57fa\u4e8e\u7684\u955c\u50cf\u540d\u79f0\uff0c\u63a5\u4e0b\u6765\u63a8\u8350\u8bf4\u660e\u7ef4\u62a4\u8005\u4fe1\u606f\u3002<\/p>\n<p>\u540e\u9762\u5219\u662f\u955c\u50cf\u64cd\u4f5c\u6307\u4ee4\uff0c\u4f8b\u5982\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff0c<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\u5c06\u5bf9\u955c\u50cf\u6267\u884c\u8ddf\u968f\u7684\u547d\u4ee4\u3002\u6bcf\u8fd0\u884c\u4e00\u6761\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff0c\u955c\u50cf\u6dfb\u52a0\u65b0\u7684\u4e00\u5c42\uff0c\u5e76\u63d0\u4ea4\u3002<\/p>\n<p>\u6700\u540e\u662f\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff0c\u6765\u6307\u5b9a\u8fd0\u884c\u5bb9\u5668\u65f6\u7684\u64cd\u4f5c\u547d\u4ee4\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u4f8b\u5b50<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;# Nginx\r\n#\r\n# VERSION               0.0.1\r\n\r\nFROM      ubuntu\r\nMAINTAINER Victor Vieux &lt;victor@docker.com&gt;\r\n\r\nRUN apt-get update &amp;&amp; apt-get install -y inotify-tools nginx apache2 openssh-server\r\n\r\n# Firefox over VNC\r\n#\r\n# VERSION               0.3\r\n\r\nFROM ubuntu\r\n\r\n# Install vnc, xvfb in order to create a 'fake' display and firefox\r\nRUN apt-get update &amp;&amp; apt-get install -y x11vnc xvfb firefox\r\nRUN mkdir \/.vnc\r\n# Setup a password\r\nRUN x11vnc -storepasswd 1234 ~\/.vnc\/passwd\r\n# Autostart firefox (might not be the best way, but it does the trick)\r\nRUN bash -c 'echo \"firefox\" &gt;&gt; \/.bashrc'\r\n\r\nEXPOSE 5900\r\nCMD    [\"x11vnc\", \"-forever\", \"-usepw\", \"-create\"]\r\n\r\n# Multiple images example\r\n#\r\n# VERSION               0.1\r\n\r\nFROM ubuntu\r\nRUN echo foo &gt; bar\r\n# Will output something like ===&gt; 907ad6c2736f\r\n\r\nFROM ubuntu\r\nRUN echo moo &gt; oink\r\n# Will output something like ===&gt; 695d7793cbe4\r\n\r\n# You?ll now have two images, 907ad6c2736f with \/bar, and 695d7793cbe4 with\r\n# \/oink.<wbr \/>de&gt;<\/pre>\n<\/div>\n<div><\/div>\n<div>\n<h2>12.2. \u6307\u4ee4<\/h2>\n<p>\u6307\u4ee4\u7684\u4e00\u822c\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;INSTRUCTION arguments<wbr \/>de&gt;\uff0c\u6307\u4ee4\u5305\u62ec\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;MAINTAINER<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u7b49\u3002<\/p>\n<h3>FROM<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM &lt;image&gt;<wbr \/>de&gt;\u6216<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM &lt;image&gt;:&lt;tag&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u7b2c\u4e00\u6761\u6307\u4ee4\u5fc5\u987b\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM<wbr \/>de&gt;\u00a0\u6307\u4ee4\u3002\u5e76\u4e14\uff0c\u5982\u679c\u5728\u540c\u4e00\u4e2aDockerfile\u4e2d\u521b\u5efa\u591a\u4e2a\u955c\u50cf\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff08\u6bcf\u4e2a\u955c\u50cf\u4e00\u6b21\uff09\u3002<\/p>\n<h3>MAINTAINER<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;MAINTAINER &lt;name&gt;<wbr \/>de&gt;\uff0c\u6307\u5b9a\u7ef4\u62a4\u8005\u4fe1\u606f\u3002<\/p>\n<h3>RUN<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN &lt;command&gt;<wbr \/>de&gt;\u00a0\u6216\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN [&#8220;executable&#8221;, &#8220;param1&#8221;, &#8220;param2&#8221;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u524d\u8005\u5c06\u5728 shell \u7ec8\u7aef\u4e2d\u8fd0\u884c\u547d\u4ee4\uff0c\u5373\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/bin\/sh -c<wbr \/>de&gt;\uff1b\u540e\u8005\u5219\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;exec<wbr \/>de&gt;\u00a0\u6267\u884c\u3002\u6307\u5b9a\u4f7f\u7528\u5176\u5b83\u7ec8\u7aef\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u4f8b\u5982\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN [&#8220;\/bin\/bash&#8221;, &#8220;-c&#8221;, &#8220;echo hello&#8221;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u6bcf\u6761\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\u5c06\u5728\u5f53\u524d\u955c\u50cf\u57fa\u7840\u4e0a\u6267\u884c\u6307\u5b9a\u547d\u4ee4\uff0c\u5e76\u63d0\u4ea4\u4e3a\u65b0\u7684\u955c\u50cf\u3002\u5f53\u547d\u4ee4\u8f83\u957f\u65f6\u53ef\u4ee5\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\\<wbr \/>de&gt;\u00a0\u6765\u6362\u884c\u3002<\/p>\n<h3>CMD<\/h3>\n<p>\u652f\u6301\u4e09\u79cd\u683c\u5f0f<\/p>\n<ul>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD [&#8220;executable&#8221;,&#8221;param1&#8243;,&#8221;param2&#8243;]<wbr \/>de&gt;\u00a0\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;exec<wbr \/>de&gt;\u00a0\u6267\u884c\uff0c\u63a8\u8350\u65b9\u5f0f\uff1b<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD command param1 param2<wbr \/>de&gt;\u00a0\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/bin\/sh<wbr \/>de&gt;\u00a0\u4e2d\u6267\u884c\uff0c\u63d0\u4f9b\u7ed9\u9700\u8981\u4ea4\u4e92\u7684\u5e94\u7528\uff1b<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD [&#8220;param1&#8243;,&#8221;param2&#8221;]<wbr \/>de&gt;\u00a0\u63d0\u4f9b\u7ed9\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT<wbr \/>de&gt;\u00a0\u7684\u9ed8\u8ba4\u53c2\u6570\uff1b<\/li>\n<\/ul>\n<p>\u6307\u5b9a\u542f\u52a8\u5bb9\u5668\u65f6\u6267\u884c\u7684\u547d\u4ee4\uff0c\u6bcf\u4e2a Dockerfile \u53ea\u80fd\u6709\u4e00\u6761\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u00a0\u547d\u4ee4\u3002\u5982\u679c\u6307\u5b9a\u4e86\u591a\u6761\u547d\u4ee4\uff0c\u53ea\u6709\u6700\u540e\u4e00\u6761\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n<p>\u5982\u679c\u7528\u6237\u542f\u52a8\u5bb9\u5668\u65f6\u5019\u6307\u5b9a\u4e86\u8fd0\u884c\u7684\u547d\u4ee4\uff0c\u5219\u4f1a\u8986\u76d6\u6389\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u00a0\u6307\u5b9a\u7684\u547d\u4ee4\u3002<\/p>\n<h3>EXPOSE<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;EXPOSE &lt;port&gt; [&lt;port&gt;&#8230;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u544a\u8bc9 Docker \u670d\u52a1\u7aef\u5bb9\u5668\u66b4\u9732\u7684\u7aef\u53e3\u53f7\uff0c\u4f9b\u4e92\u8054\u7cfb\u7edf\u4f7f\u7528\u3002\u5728\u542f\u52a8\u5bb9\u5668\u65f6\u9700\u8981\u901a\u8fc7 -P\uff0cDocker \u4e3b\u673a\u4f1a\u81ea\u52a8\u5206\u914d\u4e00\u4e2a\u7aef\u53e3\u8f6c\u53d1\u5230\u6307\u5b9a\u7684\u7aef\u53e3\u3002<\/p>\n<h3>ENV<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENV &lt;key&gt; &lt;value&gt;<wbr \/>de&gt;\u3002 \u6307\u5b9a\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\uff0c\u4f1a\u88ab\u540e\u7eed\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\u4f7f\u7528\uff0c\u5e76\u5728\u5bb9\u5668\u8fd0\u884c\u65f6\u4fdd\u6301\u3002<\/p>\n<p>\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;ENV PG_MAJOR 9.3\r\nENV PG_VERSION 9.3.4\r\nRUN curl -SL http:\/\/example.com\/postgres-$PG_VERSION.tar.xz | tar -xJC \/usr\/src\/postgress &amp;&amp; \u2026\r\nENV PATH \/usr\/local\/postgres-$PG_MAJOR\/bin:$PATH\r\n<wbr \/>de&gt;<\/pre>\n<h3>ADD<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ADD &lt;src&gt; &lt;dest&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u8be5\u547d\u4ee4\u5c06\u590d\u5236\u6307\u5b9a\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;src&gt;<wbr \/>de&gt;\u00a0\u5230\u5bb9\u5668\u4e2d\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;dest&gt;<wbr \/>de&gt;\u3002 \u5176\u4e2d\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;src&gt;<wbr \/>de&gt;\u00a0\u53ef\u4ee5\u662fDockerfile\u6240\u5728\u76ee\u5f55\u7684\u4e00\u4e2a\u76f8\u5bf9\u8def\u5f84\uff1b\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a URL\uff1b\u8fd8\u53ef\u4ee5\u662f\u4e00\u4e2a tar \u6587\u4ef6\uff08\u81ea\u52a8\u89e3\u538b\u4e3a\u76ee\u5f55\uff09\u3002<\/p>\n<h3>COPY<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;COPY &lt;src&gt; &lt;dest&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u590d\u5236\u672c\u5730\u4e3b\u673a\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;src&gt;<wbr \/>de&gt;\uff08\u4e3a Dockerfile \u6240\u5728\u76ee\u5f55\u7684\u76f8\u5bf9\u8def\u5f84\uff09\u5230\u5bb9\u5668\u4e2d\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;dest&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u5f53\u4f7f\u7528\u672c\u5730\u76ee\u5f55\u4e3a\u6e90\u76ee\u5f55\u65f6\uff0c\u63a8\u8350\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;COPY<wbr \/>de&gt;\u3002<\/p>\n<h3>ENTRYPOINT<\/h3>\n<p>\u4e24\u79cd\u683c\u5f0f\uff1a<\/p>\n<ul>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT [&#8220;executable&#8221;, &#8220;param1&#8221;, &#8220;param2&#8221;]<wbr \/>de&gt;<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT command param1 param2<wbr \/>de&gt;\uff08shell\u4e2d\u6267\u884c\uff09\u3002<\/li>\n<\/ul>\n<p>\u914d\u7f6e\u5bb9\u5668\u542f\u52a8\u540e\u6267\u884c\u7684\u547d\u4ee4\uff0c\u5e76\u4e14\u4e0d\u53ef\u88ab\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker run<wbr \/>de&gt;\u00a0\u63d0\u4f9b\u7684\u53c2\u6570\u8986\u76d6\u3002<\/p>\n<p>\u6bcf\u4e2a Dockerfile \u4e2d\u53ea\u80fd\u6709\u4e00\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT<wbr \/>de&gt;\uff0c\u5f53\u6307\u5b9a\u591a\u4e2a\u65f6\uff0c\u53ea\u6709\u6700\u540e\u4e00\u4e2a\u8d77\u6548\u3002<\/p>\n<h3>VOLUME<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;VOLUME [&#8220;\/da<wbr \/>ta&#8221;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u53ef\u4ee5\u4ece\u672c\u5730\u4e3b\u673a\u6216\u5176\u4ed6\u5bb9\u5668\u6302\u8f7d\u7684\u6302\u8f7d\u70b9\uff0c\u4e00\u822c\u7528\u6765\u5b58\u653e\u6570\u636e\u5e93\u548c\u9700\u8981\u4fdd\u6301\u7684\u6570\u636e\u7b49\u3002<\/p>\n<h3>USER<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;USER daemon<wbr \/>de&gt;\u3002<\/p>\n<p>\u6307\u5b9a\u8fd0\u884c\u5bb9\u5668\u65f6\u7684\u7528\u6237\u540d\u6216 UID\uff0c\u540e\u7eed\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u4e5f\u4f1a\u4f7f\u7528\u6307\u5b9a\u7528\u6237\u3002<\/p>\n<p>\u5f53\u670d\u52a1\u4e0d\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8be5\u547d\u4ee4\u6307\u5b9a\u8fd0\u884c\u7528\u6237\u3002\u5e76\u4e14\u53ef\u4ee5\u5728\u4e4b\u524d\u521b\u5efa\u6240\u9700\u8981\u7684\u7528\u6237\uff0c\u4f8b\u5982\uff1a<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN groupadd -r postgres &amp;&amp; useradd -r -g postgres postgres<wbr \/>de&gt;\u3002\u8981\u4e34\u65f6\u83b7\u53d6\u7ba1\u7406\u5458\u6743\u9650\u53ef\u4ee5\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;gosu<wbr \/>de&gt;\uff0c\u800c\u4e0d\u63a8\u8350\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;sudo<wbr \/>de&gt;\u3002<\/p>\n<h3>WORKDIR<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;WORKDIR \/path\/to\/workdir<wbr \/>de&gt;\u3002<\/p>\n<p>\u4e3a\u540e\u7eed\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT<wbr \/>de&gt;\u00a0\u6307\u4ee4\u914d\u7f6e\u5de5\u4f5c\u76ee\u5f55\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;WORKDIR<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff0c\u540e\u7eed\u547d\u4ee4\u5982\u679c\u53c2\u6570\u662f\u76f8\u5bf9\u8def\u5f84\uff0c\u5219\u4f1a\u57fa\u4e8e\u4e4b\u524d\u547d\u4ee4\u6307\u5b9a\u7684\u8def\u5f84\u3002\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;WORKDIR \/a\r\nWORKDIR b\r\nWORKDIR c\r\nRUN pwd\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5219\u6700\u7ec8\u8def\u5f84\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/a\/b\/c<wbr \/>de&gt;\u3002<\/p>\n<h3>ON<wbr \/>BUILD<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ON<wbr \/>BUILD [INSTRUCTION]<wbr \/>de&gt;\u3002<\/p>\n<p>\u914d\u7f6e\u5f53\u6240\u521b\u5efa\u7684\u955c\u50cf\u4f5c\u4e3a\u5176\u5b83\u65b0\u521b\u5efa\u955c\u50cf\u7684\u57fa\u7840\u955c\u50cf\u65f6\uff0c\u6240\u6267\u884c\u7684\u64cd\u4f5c\u6307\u4ee4\u3002<\/p>\n<p>\u4f8b\u5982\uff0cDockerfile \u4f7f\u7528\u5982\u4e0b\u7684\u5185\u5bb9\u521b\u5efa\u4e86\u955c\u50cf\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;image-A<wbr \/>de&gt;\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;[...]\r\nON<wbr \/>BUILD ADD . \/app\/src\r\nON<wbr \/>BUILD RUN \/usr\/local\/bin\/python-build --dir \/app\/src\r\n[...]\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5982\u679c\u57fa\u4e8e image-A \u521b\u5efa\u65b0\u7684\u955c\u50cf\u65f6\uff0c\u65b0\u7684Dockerfile\u4e2d\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM image-A<wbr \/>de&gt;\u6307\u5b9a\u57fa\u7840\u955c\u50cf\u65f6\uff0c\u4f1a\u81ea\u52a8\u6267\u884c<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ON<wbr \/>BUILD<wbr \/>de&gt;\u00a0\u6307\u4ee4\u5185\u5bb9\uff0c\u7b49\u4ef7\u4e8e\u5728\u540e\u9762\u6dfb\u52a0\u4e86\u4e24\u6761\u6307\u4ee4\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;FROM image-A\r\n\r\n#Automatically run the following\r\nADD . \/app\/src\r\nRUN \/usr\/local\/bin\/python-build --dir \/app\/src\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ON<wbr \/>BUILD<wbr \/>de&gt;\u00a0\u6307\u4ee4\u7684\u955c\u50cf\uff0c\u63a8\u8350\u5728\u6807\u7b7e\u4e2d\u6ce8\u660e\uff0c\u4f8b\u5982\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ruby:1.9-on<wbr \/>build<wbr \/>de&gt;\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>12.3. \u521b\u5efa\u955c\u50cf<\/h2>\n<p>\u7f16\u5199\u5b8c\u6210 Dockerfile \u4e4b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker build<wbr \/>de&gt;\u00a0\u547d\u4ee4\u6765\u521b\u5efa\u955c\u50cf\u3002<\/p>\n<p>\u57fa\u672c\u7684\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker build [\u9009\u9879] \u8def\u5f84<wbr \/>de&gt;\uff0c\u8be5\u547d\u4ee4\u5c06\u8bfb\u53d6\u6307\u5b9a\u8def\u5f84\u4e0b\uff08\u5305\u62ec\u5b50\u76ee\u5f55\uff09\u7684 Dockerfile\uff0c\u5e76\u5c06\u8be5\u8def\u5f84\u4e0b\u6240\u6709\u5185\u5bb9\u53d1\u9001\u7ed9 Docker \u670d\u52a1\u7aef\uff0c\u7531\u670d\u52a1\u7aef\u6765\u521b\u5efa\u955c\u50cf\u3002\u56e0\u6b64\u4e00\u822c\u5efa\u8bae\u653e\u7f6e Dockerfile \u7684\u76ee\u5f55\u4e3a\u7a7a\u76ee\u5f55\u3002\u4e5f\u53ef\u4ee5\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;.dockerignore<wbr \/>de&gt;\u00a0\u6587\u4ef6\uff08\u6bcf\u4e00\u884c\u6dfb\u52a0\u4e00\u6761\u5339\u914d\u6a21\u5f0f\uff09\u6765\u8ba9 Docker \u5ffd\u7565\u8def\u5f84\u4e0b\u7684\u76ee\u5f55\u548c\u6587\u4ef6\u3002<\/p>\n<p>\u8981\u6307\u5b9a\u955c\u50cf\u7684\u6807\u7b7e\u4fe1\u606f\uff0c\u53ef\u4ee5\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-t<wbr \/>de&gt;\u00a0\u9009\u9879\uff0c\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker build -t myrepo\/myapp \/tmp\/test1\/<wbr \/>de&gt;<\/pre>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<h1>13. \u5e95\u5c42\u5b9e\u73b0<\/h1>\n<p>Docker \u5e95\u5c42\u7684\u6838\u5fc3\u6280\u672f\u5305\u62ec Linux \u4e0a\u7684\u540d\u5b57\u7a7a\u95f4\uff08Namespaces\uff09\u3001\u63a7\u5236\u7ec4\uff08Control groups\uff09\u3001Union \u6587\u4ef6\u7cfb\u7edf\uff08Union file systems\uff09\u548c\u5bb9\u5668\u683c\u5f0f\uff08Container format\uff09\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053\uff0c\u4f20\u7edf\u7684\u865a\u62df\u673a\u901a\u8fc7\u5728\u5bbf\u4e3b\u4e3b\u673a\u4e2d\u8fd0\u884c hypervisor \u6765\u6a21\u62df\u4e00\u6574\u5957\u5b8c\u6574\u7684\u786c\u4ef6\u73af\u5883\u63d0\u4f9b\u7ed9\u865a\u62df\u673a\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002\u865a\u62df\u673a\u7cfb\u7edf\u770b\u5230\u7684\u73af\u5883\u662f\u53ef\u9650\u5236\u7684\uff0c\u4e5f\u662f\u5f7c\u6b64\u9694\u79bb\u7684\u3002 \u8fd9\u79cd\u76f4\u63a5\u7684\u505a\u6cd5\u5b9e\u73b0\u4e86\u5bf9\u8d44\u6e90\u6700\u5b8c\u6574\u7684\u5c01\u88c5\uff0c\u4f46\u5f88\u591a\u65f6\u5019\u5f80\u5f80\u610f\u5473\u7740\u7cfb\u7edf\u8d44\u6e90\u7684\u6d6a\u8d39\u3002 \u4f8b\u5982\uff0c\u4ee5\u5bbf\u4e3b\u673a\u548c\u865a\u62df\u673a\u7cfb\u7edf\u90fd\u4e3a Linux \u7cfb\u7edf\u4e3a\u4f8b\uff0c\u865a\u62df\u673a\u4e2d\u8fd0\u884c\u7684\u5e94\u7528\u5176\u5b9e\u53ef\u4ee5\u5229\u7528\u5bbf\u4e3b\u673a\u7cfb\u7edf\u4e2d\u7684\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053\uff0c\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u5305\u62ec\u5185\u6838\u3001\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u3001PID\u3001UID\u3001IPC\u3001\u5185\u5b58\u3001\u786c\u76d8\u3001CPU \u7b49\u7b49\uff0c\u6240\u6709\u7684\u8d44\u6e90\u90fd\u662f\u5e94\u7528\u8fdb\u7a0b\u76f4\u63a5\u5171\u4eab\u7684\u3002 \u8981\u60f3\u5b9e\u73b0\u865a\u62df\u5316\uff0c\u9664\u4e86\u8981\u5b9e\u73b0\u5bf9\u5185\u5b58\u3001CPU\u3001\u7f51\u7edcIO\u3001\u786c\u76d8IO\u3001\u5b58\u50a8\u7a7a\u95f4\u7b49\u7684\u9650\u5236\u5916\uff0c\u8fd8\u8981\u5b9e\u73b0\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u3001PID\u3001UID\u3001IPC\u7b49\u7b49\u7684\u76f8\u4e92\u9694\u79bb\u3002 \u524d\u8005\u76f8\u5bf9\u5bb9\u6613\u5b9e\u73b0\u4e00\u4e9b\uff0c\u540e\u8005\u5219\u9700\u8981\u5bbf\u4e3b\u673a\u7cfb\u7edf\u7684\u6df1\u5165\u652f\u6301\u3002<\/p>\n<p>\u968f\u7740 Linux \u7cfb\u7edf\u5bf9\u4e8e\u540d\u5b57\u7a7a\u95f4\u529f\u80fd\u7684\u5b8c\u5584\u5b9e\u73b0\uff0c\u7a0b\u5e8f\u5458\u5df2\u7ecf\u53ef\u4ee5\u5b9e\u73b0\u4e0a\u9762\u7684\u6240\u6709\u9700\u6c42\uff0c\u8ba9\u67d0\u4e9b\u8fdb\u7a0b\u5728\u5f7c\u6b64\u9694\u79bb\u7684\u540d\u5b57\u7a7a\u95f4\u4e2d\u8fd0\u884c\u3002\u5927\u5bb6\u867d\u7136\u90fd\u5171\u7528\u4e00\u4e2a\u5185\u6838\u548c\u67d0\u4e9b\u8fd0\u884c\u65f6\u73af\u5883\uff08\u4f8b\u5982\u4e00\u4e9b\u7cfb\u7edf\u547d\u4ee4\u548c\u7cfb\u7edf\u5e93\uff09\uff0c\u4f46\u662f\u5f7c\u6b64\u5374\u770b\u4e0d\u5230\uff0c\u90fd\u4ee5\u4e3a\u7cfb\u7edf\u4e2d\u53ea\u6709\u81ea\u5df1\u7684\u5b58\u5728\u3002\u8fd9\u79cd\u673a\u5236\u5c31\u662f\u5bb9\u5668\uff08Container\uff09\uff0c\u5229\u7528\u540d\u5b57\u7a7a\u95f4\u6765\u505a\u6743\u9650\u7684\u9694\u79bb\u63a7\u5236\uff0c\u5229\u7528 cgroups \u6765\u505a\u8d44\u6e90\u5206\u914d\u3002<\/p>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<h2>13.1. \u57fa\u672c\u67b6\u6784<\/h2>\n<p>Docker \u91c7\u7528\u4e86 C\/S\u67b6\u6784\uff0c\u5305\u62ec\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u3002 Docker daemon \u4f5c\u4e3a\u670d\u52a1\u7aef\u63a5\u53d7\u6765\u81ea\u5ba2\u6237\u7684\u8bf7\u6c42\uff0c\u5e76\u5904\u7406\u8fd9\u4e9b\u8bf7\u6c42\uff08\u521b\u5efa\u3001\u8fd0\u884c\u3001\u5206\u53d1\u5bb9\u5668\uff09\u3002 \u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef\u65e2\u53ef\u4ee5\u8fd0\u884c\u5728\u4e00\u4e2a\u673a\u5668\u4e0a\uff0c\u4e5f\u53ef\u901a\u8fc7 socket \u6216\u8005 RESTful API \u6765\u8fdb\u884c\u901a\u4fe1\u3002<\/p>\n<p>Docker daemon \u4e00\u822c\u5728\u5bbf\u4e3b\u4e3b\u673a\u540e\u53f0\u8fd0\u884c\uff0c\u7b49\u5f85\u63a5\u6536\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u6d88\u606f\u3002 Docker \u5ba2\u6237\u7aef\u5219\u4e3a\u7528\u6237\u63d0\u4f9b\u4e00\u7cfb\u5217\u53ef\u6267\u884c\u547d\u4ee4\uff0c\u7528\u6237\u7528\u8fd9\u4e9b\u547d\u4ee4\u5b9e\u73b0\u8ddf Docker daemon \u4ea4\u4e92\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>13.2. \u540d\u5b57\u7a7a\u95f4<\/h2>\n<p>\u540d\u5b57\u7a7a\u95f4\u662f Linux \u5185\u6838\u4e00\u4e2a\u5f3a\u5927\u7684\u7279\u6027\u3002\u6bcf\u4e2a\u5bb9\u5668\u90fd\u6709\u81ea\u5df1\u5355\u72ec\u7684\u540d\u5b57\u7a7a\u95f4\uff0c\u8fd0\u884c\u5728\u5176\u4e2d\u7684\u5e94\u7528\u90fd\u50cf\u662f\u5728\u72ec\u7acb\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u8fd0\u884c\u4e00\u6837\u3002\u540d\u5b57\u7a7a\u95f4\u4fdd\u8bc1\u4e86\u5bb9\u5668\u4e4b\u95f4\u5f7c\u6b64\u4e92\u4e0d\u5f71\u54cd\u3002<\/p>\n<h3>pid \u540d\u5b57\u7a7a\u95f4<\/h3>\n<p>\u4e0d\u540c\u7528\u6237\u7684\u8fdb\u7a0b\u5c31\u662f\u901a\u8fc7 pid \u540d\u5b57\u7a7a\u95f4\u9694\u79bb\u5f00\u7684\uff0c\u4e14\u4e0d\u540c\u540d\u5b57\u7a7a\u95f4\u4e2d\u53ef\u4ee5\u6709\u76f8\u540c pid\u3002\u6240\u6709\u7684 LXC \u8fdb\u7a0b\u5728 Docker \u4e2d\u7684\u7236\u8fdb\u7a0b\u4e3aDocker\u8fdb\u7a0b\uff0c\u6bcf\u4e2a LXC \u8fdb\u7a0b\u5177\u6709\u4e0d\u540c\u7684\u540d\u5b57\u7a7a\u95f4\u3002\u540c\u65f6\u7531\u4e8e\u5141\u8bb8\u5d4c\u5957\uff0c\u56e0\u6b64\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5b9e\u73b0\u5d4c\u5957\u7684 Docker \u5bb9\u5668\u3002<\/p>\n<h3>net \u540d\u5b57\u7a7a\u95f4<\/h3>\n<p>\u6709\u4e86 pid \u540d\u5b57\u7a7a\u95f4, \u6bcf\u4e2a\u540d\u5b57\u7a7a\u95f4\u4e2d\u7684 pid \u80fd\u591f\u76f8\u4e92\u9694\u79bb\uff0c\u4f46\u662f\u7f51\u7edc\u7aef\u53e3\u8fd8\u662f\u5171\u4eab host \u7684\u7aef\u53e3\u3002\u7f51\u7edc\u9694\u79bb\u662f\u901a\u8fc7 net \u540d\u5b57\u7a7a\u95f4\u5b9e\u73b0\u7684\uff0c \u6bcf\u4e2a net \u540d\u5b57\u7a7a\u95f4\u6709\u72ec\u7acb\u7684 \u7f51\u7edc\u8bbe\u5907, IP \u5730\u5740, \u8def\u7531\u8868, \/proc\/net \u76ee\u5f55\u3002\u8fd9\u6837\u6bcf\u4e2a\u5bb9\u5668\u7684\u7f51\u7edc\u5c31\u80fd\u9694\u79bb\u5f00\u6765\u3002Docker \u9ed8\u8ba4\u91c7\u7528 veth \u7684\u65b9\u5f0f\uff0c\u5c06\u5bb9\u5668\u4e2d\u7684\u865a\u62df\u7f51\u5361\u540c host \u4e0a\u7684\u4e00 \u4e2aDocker \u7f51\u6865 docker0 \u8fde\u63a5\u5728\u4e00\u8d77\u3002<\/p>\n<h3>ipc \u540d\u5b57\u7a7a\u95f4<\/h3>\n<p>\u5bb9\u5668\u4e2d\u8fdb\u7a0b\u4ea4\u4e92\u8fd8\u662f\u91c7\u7528\u4e86 Linux \u5e38\u89c1\u7684\u8fdb\u7a0b\u95f4\u4ea4\u4e92\u65b9\u6cd5(interprocess communication &#8211; IPC), \u5305\u62ec\u4fe1\u53f7\u91cf\u3001\u6d88\u606f\u961f\u5217\u548c\u5171\u4eab\u5185\u5b58\u7b49\u3002\u7136\u800c\u540c VM \u4e0d\u540c\u7684\u662f\uff0c\u5bb9\u5668\u7684\u8fdb\u7a0b\u95f4\u4ea4\u4e92\u5b9e\u9645\u4e0a\u8fd8\u662f host \u4e0a\u5177\u6709\u76f8\u540c pid \u540d\u5b57\u7a7a\u95f4\u4e2d\u7684\u8fdb\u7a0b\u95f4\u4ea4\u4e92\uff0c\u56e0\u6b64\u9700\u8981\u5728 IPC \u8d44\u6e90\u7533\u8bf7\u65f6\u52a0\u5165\u540d\u5b57\u7a7a\u95f4\u4fe1\u606f\uff0c\u6bcf\u4e2a IPC \u8d44\u6e90\u6709\u4e00\u4e2a\u552f\u4e00\u7684 32 \u4f4d id\u3002<\/p>\n<h3>mnt \u540d\u5b57\u7a7a\u95f4<\/h3>\n<p>\u7c7b\u4f3c chroot\uff0c\u5c06\u4e00\u4e2a\u8fdb\u7a0b\u653e\u5230\u4e00\u4e2a\u7279\u5b9a\u7684\u76ee\u5f55\u6267\u884c\u3002mnt \u540d\u5b57\u7a7a\u95f4\u5141\u8bb8\u4e0d\u540c\u540d\u5b57\u7a7a\u95f4\u7684\u8fdb\u7a0b\u770b\u5230\u7684\u6587\u4ef6\u7ed3\u6784\u4e0d\u540c\uff0c\u8fd9\u6837\u6bcf\u4e2a\u540d\u5b57\u7a7a\u95f4 \u4e2d\u7684\u8fdb\u7a0b\u6240\u770b\u5230\u7684\u6587\u4ef6\u76ee\u5f55\u5c31\u88ab\u9694\u79bb\u5f00\u4e86\u3002\u540c chroot \u4e0d\u540c\uff0c\u6bcf\u4e2a\u540d\u5b57\u7a7a\u95f4\u4e2d\u7684\u5bb9\u5668\u5728 \/proc\/mounts \u7684\u4fe1\u606f\u53ea\u5305\u542b\u6240\u5728\u540d\u5b57\u7a7a\u95f4\u7684 mount point\u3002<\/p>\n<h3>uts \u540d\u5b57\u7a7a\u95f4<\/h3>\n<p>UTS(&#8220;UNIX Time-sharing System&#8221;) \u540d\u5b57\u7a7a\u95f4\u5141\u8bb8\u6bcf\u4e2a\u5bb9\u5668\u62e5\u6709\u72ec\u7acb\u7684 hostname \u548c domain name, \u4f7f\u5176\u5728\u7f51\u7edc\u4e0a\u53ef\u4ee5\u88ab\u89c6\u4f5c\u4e00\u4e2a\u72ec\u7acb\u7684\u8282\u70b9\u800c\u975e \u4e3b\u673a\u4e0a\u7684\u4e00\u4e2a\u8fdb\u7a0b\u3002<\/p>\n<h3>user \u540d\u5b57\u7a7a\u95f4<\/h3>\n<p>\u6bcf\u4e2a\u5bb9\u5668\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u7528\u6237\u548c\u7ec4 id, \u4e5f\u5c31\u662f\u8bf4\u53ef\u4ee5\u5728\u5bb9\u5668\u5185\u7528\u5bb9\u5668\u5185\u90e8\u7684\u7528\u6237\u6267\u884c\u7a0b\u5e8f\u800c\u975e\u4e3b\u673a\u4e0a\u7684\u7528\u6237\u3002<\/p>\n<p>*\u6ce8\uff1a\u5173\u4e8e Linux \u4e0a\u7684\u540d\u5b57\u7a7a\u95f4\uff0c<a href=\"http:\/\/blog.scottlowe.org\/2013\/09\/04\/introducing-linux-network-namespaces\/\" target=\"_blank\" rel=\"nofollow noopener\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\u00a0\u4ecb\u7ecd\u7684\u5f88\u597d\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>13.3. \u63a7\u5236\u7ec4<\/h2>\n<p>\u63a7\u5236\u7ec4\uff08<a href=\"http:\/\/en.wikipedia.org\/wiki\/Cgroups\" target=\"_blank\" rel=\"nofollow noopener\">cgroups<\/a>\uff09\u662f Linux \u5185\u6838\u7684\u4e00\u4e2a\u7279\u6027\uff0c\u4e3b\u8981\u7528\u6765\u5bf9\u5171\u4eab\u8d44\u6e90\u8fdb\u884c\u9694\u79bb\u3001\u9650\u5236\u3001\u5ba1\u8ba1\u7b49\u3002\u53ea\u6709\u80fd\u63a7\u5236\u5206\u914d\u5230\u5bb9\u5668\u7684\u8d44\u6e90\uff0c\u624d\u80fd\u907f\u514d\u5f53\u591a\u4e2a\u5bb9\u5668\u540c\u65f6\u8fd0\u884c\u65f6\u7684\u5bf9\u7cfb\u7edf\u8d44\u6e90\u7684\u7ade\u4e89\u3002<\/p>\n<p>\u63a7\u5236\u7ec4\u6280\u672f\u6700\u65e9\u662f\u7531 Google \u7684\u7a0b\u5e8f\u5458 2006 \u5e74\u8d77\u63d0\u51fa\uff0cLinux \u5185\u6838\u81ea 2.6.24 \u5f00\u59cb\u652f\u6301\u3002<\/p>\n<p>\u63a7\u5236\u7ec4\u53ef\u4ee5\u63d0\u4f9b\u5bf9\u5bb9\u5668\u7684\u5185\u5b58\u3001CPU\u3001\u78c1\u76d8 IO \u7b49\u8d44\u6e90\u7684\u9650\u5236\u548c\u5ba1\u8ba1\u7ba1\u7406\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>13.4. Union \u6587\u4ef6\u7cfb\u7edf<\/h2>\n<p>Union\u6587\u4ef6\u7cfb\u7edf\uff08<a href=\"http:\/\/en.wikipedia.org\/wiki\/UnionFS\" target=\"_blank\" rel=\"nofollow noopener\">UnionFS<\/a>\uff09\u662f\u4e00\u79cd\u5206\u5c42\u3001\u8f7b\u91cf\u7ea7\u5e76\u4e14\u9ad8\u6027\u80fd\u7684\u6587\u4ef6\u7cfb\u7edf\uff0c\u5b83\u652f\u6301\u5bf9\u6587\u4ef6\u7cfb\u7edf\u7684\u4fee\u6539\u4f5c\u4e3a\u4e00\u6b21\u63d0\u4ea4\u6765\u4e00\u5c42\u5c42\u7684\u53e0\u52a0\uff0c\u540c\u65f6\u53ef\u4ee5\u5c06\u4e0d\u540c\u76ee\u5f55\u6302\u8f7d\u5230\u540c\u4e00\u4e2a\u865a\u62df\u6587\u4ef6\u7cfb\u7edf\u4e0b(unite several directories into a single virtual filesystem)\u3002<\/p>\n<p>Union \u6587\u4ef6\u7cfb\u7edf\u662f Docker \u955c\u50cf\u7684\u57fa\u7840\u3002\u955c\u50cf\u53ef\u4ee5\u901a\u8fc7\u5206\u5c42\u6765\u8fdb\u884c\u7ee7\u627f\uff0c\u57fa\u4e8e\u57fa\u7840\u955c\u50cf\uff08\u6ca1\u6709\u7236\u955c\u50cf\uff09\uff0c\u53ef\u4ee5\u5236\u4f5c\u5404\u79cd\u5177\u4f53\u7684\u5e94\u7528\u955c\u50cf\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u4e0d\u540c Docker \u5bb9\u5668\u5c31\u53ef\u4ee5\u5171\u4eab\u4e00\u4e9b\u57fa\u7840\u7684\u6587\u4ef6\u7cfb\u7edf\u5c42\uff0c\u540c\u65f6\u518d\u52a0\u4e0a\u81ea\u5df1\u72ec\u6709\u7684\u6539\u52a8\u5c42\uff0c\u5927\u5927\u63d0\u9ad8\u4e86\u5b58\u50a8\u7684\u6548\u7387\u3002<\/p>\n<p>Docker \u4e2d\u4f7f\u7528\u7684 AUFS\uff08AnotherUnionFS\uff09\u5c31\u662f\u4e00\u79cd Union FS\u3002 AUFS \u652f\u6301\u4e3a\u6bcf\u4e00\u4e2a\u6210\u5458\u76ee\u5f55\uff08\u7c7b\u4f3c Git \u7684\u5206\u652f\uff09\u8bbe\u5b9a\u53ea\u8bfb\uff08readonly\uff09\u3001\u8bfb\u5199\uff08readwrite\uff09\u548c\u5199\u51fa\uff08whiteout-able\uff09\u6743\u9650, \u540c\u65f6 AUFS \u91cc\u6709\u4e00\u4e2a\u7c7b\u4f3c\u5206\u5c42\u7684\u6982\u5ff5, \u5bf9\u53ea\u8bfb\u6743\u9650\u7684\u5206\u652f\u53ef\u4ee5\u903b\u8f91\u4e0a\u8fdb\u884c\u589e\u91cf\u5730\u4fee\u6539(\u4e0d\u5f71\u54cd\u53ea\u8bfb\u90e8\u5206\u7684)\u3002<\/p>\n<p>Docker \u76ee\u524d\u652f\u6301\u7684 Union \u6587\u4ef6\u7cfb\u7edf\u79cd\u7c7b\u5305\u62ec AUFS, btrfs, vfs \u548c DeviceMapper\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>13.5. \u5bb9\u5668\u683c\u5f0f<\/h2>\n<p>\u6700\u521d\uff0cDocker \u91c7\u7528\u4e86 LXC \u4e2d\u7684\u5bb9\u5668\u683c\u5f0f\u3002\u81ea 1.20 \u7248\u672c\u5f00\u59cb\uff0cDocker \u4e5f\u5f00\u59cb\u652f\u6301\u65b0\u7684\u00a0<a href=\"https:\/\/github.com\/docker\/libcontainer\" target=\"_blank\" rel=\"nofollow noopener\">libcontainer<\/a>\u00a0\u683c\u5f0f\uff0c\u5e76\u4f5c\u4e3a\u9ed8\u8ba4\u9009\u9879\u3002<\/p>\n<p>\u5bf9\u66f4\u591a\u5bb9\u5668\u683c\u5f0f\u7684\u652f\u6301\uff0c\u8fd8\u5728\u8fdb\u4e00\u6b65\u7684\u53d1\u5c55\u4e2d\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>\u6307\u4ee4<\/h2>\n<p>\u6307\u4ee4\u7684\u4e00\u822c\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;INSTRUCTION arguments<wbr \/>de&gt;\uff0c\u6307\u4ee4\u5305\u62ec\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;MAINTAINER<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u7b49\u3002<\/p>\n<h3>FROM<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM &lt;image&gt;<wbr \/>de&gt;\u6216<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM &lt;image&gt;:&lt;tag&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u7b2c\u4e00\u6761\u6307\u4ee4\u5fc5\u987b\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM<wbr \/>de&gt;\u00a0\u6307\u4ee4\u3002\u5e76\u4e14\uff0c\u5982\u679c\u5728\u540c\u4e00\u4e2aDockerfile\u4e2d\u521b\u5efa\u591a\u4e2a\u955c\u50cf\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff08\u6bcf\u4e2a\u955c\u50cf\u4e00\u6b21\uff09\u3002<\/p>\n<h3>MAINTAINER<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;MAINTAINER &lt;name&gt;<wbr \/>de&gt;\uff0c\u6307\u5b9a\u7ef4\u62a4\u8005\u4fe1\u606f\u3002<\/p>\n<h3>RUN<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN &lt;command&gt;<wbr \/>de&gt;\u00a0\u6216\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN [&#8220;executable&#8221;, &#8220;param1&#8221;, &#8220;param2&#8221;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u524d\u8005\u5c06\u5728 shell \u7ec8\u7aef\u4e2d\u8fd0\u884c\u547d\u4ee4\uff0c\u5373\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/bin\/sh -c<wbr \/>de&gt;\uff1b\u540e\u8005\u5219\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;exec<wbr \/>de&gt;\u00a0\u6267\u884c\u3002\u6307\u5b9a\u4f7f\u7528\u5176\u5b83\u7ec8\u7aef\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u4f8b\u5982\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN [&#8220;\/bin\/bash&#8221;, &#8220;-c&#8221;, &#8220;echo hello&#8221;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u6bcf\u6761\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\u5c06\u5728\u5f53\u524d\u955c\u50cf\u57fa\u7840\u4e0a\u6267\u884c\u6307\u5b9a\u547d\u4ee4\uff0c\u5e76\u63d0\u4ea4\u4e3a\u65b0\u7684\u955c\u50cf\u3002\u5f53\u547d\u4ee4\u8f83\u957f\u65f6\u53ef\u4ee5\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\\<wbr \/>de&gt;\u00a0\u6765\u6362\u884c\u3002<\/p>\n<h3>CMD<\/h3>\n<p>\u652f\u6301\u4e09\u79cd\u683c\u5f0f<\/p>\n<ul>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD [&#8220;executable&#8221;,&#8221;param1&#8243;,&#8221;param2&#8243;]<wbr \/>de&gt;\u00a0\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;exec<wbr \/>de&gt;\u00a0\u6267\u884c\uff0c\u63a8\u8350\u65b9\u5f0f\uff1b<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD command param1 param2<wbr \/>de&gt;\u00a0\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/bin\/sh<wbr \/>de&gt;\u00a0\u4e2d\u6267\u884c\uff0c\u63d0\u4f9b\u7ed9\u9700\u8981\u4ea4\u4e92\u7684\u5e94\u7528\uff1b<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD [&#8220;param1&#8243;,&#8221;param2&#8221;]<wbr \/>de&gt;\u00a0\u63d0\u4f9b\u7ed9\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT<wbr \/>de&gt;\u00a0\u7684\u9ed8\u8ba4\u53c2\u6570\uff1b<\/li>\n<\/ul>\n<p>\u6307\u5b9a\u542f\u52a8\u5bb9\u5668\u65f6\u6267\u884c\u7684\u547d\u4ee4\uff0c\u6bcf\u4e2a Dockerfile \u53ea\u80fd\u6709\u4e00\u6761\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u00a0\u547d\u4ee4\u3002\u5982\u679c\u6307\u5b9a\u4e86\u591a\u6761\u547d\u4ee4\uff0c\u53ea\u6709\u6700\u540e\u4e00\u6761\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n<p>\u5982\u679c\u7528\u6237\u542f\u52a8\u5bb9\u5668\u65f6\u5019\u6307\u5b9a\u4e86\u8fd0\u884c\u7684\u547d\u4ee4\uff0c\u5219\u4f1a\u8986\u76d6\u6389\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u00a0\u6307\u5b9a\u7684\u547d\u4ee4\u3002<\/p>\n<h3>EXPOSE<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;EXPOSE &lt;port&gt; [&lt;port&gt;&#8230;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u544a\u8bc9 Docker \u670d\u52a1\u7aef\u5bb9\u5668\u66b4\u9732\u7684\u7aef\u53e3\u53f7\uff0c\u4f9b\u4e92\u8054\u7cfb\u7edf\u4f7f\u7528\u3002\u5728\u542f\u52a8\u5bb9\u5668\u65f6\u9700\u8981\u901a\u8fc7 -P\uff0cDocker \u4e3b\u673a\u4f1a\u81ea\u52a8\u5206\u914d\u4e00\u4e2a\u7aef\u53e3\u8f6c\u53d1\u5230\u6307\u5b9a\u7684\u7aef\u53e3\u3002<\/p>\n<h3>ENV<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENV &lt;key&gt; &lt;value&gt;<wbr \/>de&gt;\u3002 \u6307\u5b9a\u4e00\u4e2a\u73af\u5883\u53d8\u91cf\uff0c\u4f1a\u88ab\u540e\u7eed\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u6307\u4ee4\u4f7f\u7528\uff0c\u5e76\u5728\u5bb9\u5668\u8fd0\u884c\u65f6\u4fdd\u6301\u3002<\/p>\n<p>\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;ENV PG_MAJOR 9.3\r\nENV PG_VERSION 9.3.4\r\nRUN curl -SL http:\/\/example.com\/postgres-$PG_VERSION.tar.xz | tar -xJC \/usr\/src\/postgress &amp;&amp; \u2026\r\nENV PATH \/usr\/local\/postgres-$PG_MAJOR\/bin:$PATH\r\n<wbr \/>de&gt;<\/pre>\n<h3>ADD<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ADD &lt;src&gt; &lt;dest&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u8be5\u547d\u4ee4\u5c06\u590d\u5236\u6307\u5b9a\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;src&gt;<wbr \/>de&gt;\u00a0\u5230\u5bb9\u5668\u4e2d\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;dest&gt;<wbr \/>de&gt;\u3002 \u5176\u4e2d\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;src&gt;<wbr \/>de&gt;\u00a0\u53ef\u4ee5\u662fDockerfile\u6240\u5728\u76ee\u5f55\u7684\u4e00\u4e2a\u76f8\u5bf9\u8def\u5f84\uff1b\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a URL\uff1b\u8fd8\u53ef\u4ee5\u662f\u4e00\u4e2a tar \u6587\u4ef6\uff08\u81ea\u52a8\u89e3\u538b\u4e3a\u76ee\u5f55\uff09\u3002<\/p>\n<h3>COPY<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;COPY &lt;src&gt; &lt;dest&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u590d\u5236\u672c\u5730\u4e3b\u673a\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;src&gt;<wbr \/>de&gt;\uff08\u4e3a Dockerfile \u6240\u5728\u76ee\u5f55\u7684\u76f8\u5bf9\u8def\u5f84\uff09\u5230\u5bb9\u5668\u4e2d\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&lt;dest&gt;<wbr \/>de&gt;\u3002<\/p>\n<p>\u5f53\u4f7f\u7528\u672c\u5730\u76ee\u5f55\u4e3a\u6e90\u76ee\u5f55\u65f6\uff0c\u63a8\u8350\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;COPY<wbr \/>de&gt;\u3002<\/p>\n<h3>ENTRYPOINT<\/h3>\n<p>\u4e24\u79cd\u683c\u5f0f\uff1a<\/p>\n<ul>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT [&#8220;executable&#8221;, &#8220;param1&#8221;, &#8220;param2&#8221;]<wbr \/>de&gt;<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT command param1 param2<wbr \/>de&gt;\uff08shell\u4e2d\u6267\u884c\uff09\u3002<\/li>\n<\/ul>\n<p>\u914d\u7f6e\u5bb9\u5668\u542f\u52a8\u540e\u6267\u884c\u7684\u547d\u4ee4\uff0c\u5e76\u4e14\u4e0d\u53ef\u88ab\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker run<wbr \/>de&gt;\u00a0\u63d0\u4f9b\u7684\u53c2\u6570\u8986\u76d6\u3002<\/p>\n<p>\u6bcf\u4e2a Dockerfile \u4e2d\u53ea\u80fd\u6709\u4e00\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT<wbr \/>de&gt;\uff0c\u5f53\u6307\u5b9a\u591a\u4e2a\u65f6\uff0c\u53ea\u6709\u6700\u540e\u4e00\u4e2a\u8d77\u6548\u3002<\/p>\n<h3>VOLUME<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;VOLUME [&#8220;\/da<wbr \/>ta&#8221;]<wbr \/>de&gt;\u3002<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u53ef\u4ee5\u4ece\u672c\u5730\u4e3b\u673a\u6216\u5176\u4ed6\u5bb9\u5668\u6302\u8f7d\u7684\u6302\u8f7d\u70b9\uff0c\u4e00\u822c\u7528\u6765\u5b58\u653e\u6570\u636e\u5e93\u548c\u9700\u8981\u4fdd\u6301\u7684\u6570\u636e\u7b49\u3002<\/p>\n<h3>USER<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;USER daemon<wbr \/>de&gt;\u3002<\/p>\n<p>\u6307\u5b9a\u8fd0\u884c\u5bb9\u5668\u65f6\u7684\u7528\u6237\u540d\u6216 UID\uff0c\u540e\u7eed\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u00a0\u4e5f\u4f1a\u4f7f\u7528\u6307\u5b9a\u7528\u6237\u3002<\/p>\n<p>\u5f53\u670d\u52a1\u4e0d\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8be5\u547d\u4ee4\u6307\u5b9a\u8fd0\u884c\u7528\u6237\u3002\u5e76\u4e14\u53ef\u4ee5\u5728\u4e4b\u524d\u521b\u5efa\u6240\u9700\u8981\u7684\u7528\u6237\uff0c\u4f8b\u5982\uff1a<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN groupadd -r postgres &amp;&amp; useradd -r -g postgres postgres<wbr \/>de&gt;\u3002\u8981\u4e34\u65f6\u83b7\u53d6\u7ba1\u7406\u5458\u6743\u9650\u53ef\u4ee5\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;gosu<wbr \/>de&gt;\uff0c\u800c\u4e0d\u63a8\u8350\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;sudo<wbr \/>de&gt;\u3002<\/p>\n<h3>WORKDIR<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;WORKDIR \/path\/to\/workdir<wbr \/>de&gt;\u3002<\/p>\n<p>\u4e3a\u540e\u7eed\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;RUN<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;CMD<wbr \/>de&gt;\u3001<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ENTRYPOINT<wbr \/>de&gt;\u00a0\u6307\u4ee4\u914d\u7f6e\u5de5\u4f5c\u76ee\u5f55\u3002<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u591a\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;WORKDIR<wbr \/>de&gt;\u00a0\u6307\u4ee4\uff0c\u540e\u7eed\u547d\u4ee4\u5982\u679c\u53c2\u6570\u662f\u76f8\u5bf9\u8def\u5f84\uff0c\u5219\u4f1a\u57fa\u4e8e\u4e4b\u524d\u547d\u4ee4\u6307\u5b9a\u7684\u8def\u5f84\u3002\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;WORKDIR \/a\r\nWORKDIR b\r\nWORKDIR c\r\nRUN pwd\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5219\u6700\u7ec8\u8def\u5f84\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/a\/b\/c<wbr \/>de&gt;\u3002<\/p>\n<h3>ON<wbr \/>BUILD<\/h3>\n<p>\u683c\u5f0f\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ON<wbr \/>BUILD [INSTRUCTION]<wbr \/>de&gt;\u3002<\/p>\n<p>\u914d\u7f6e\u5f53\u6240\u521b\u5efa\u7684\u955c\u50cf\u4f5c\u4e3a\u5176\u5b83\u65b0\u521b\u5efa\u955c\u50cf\u7684\u57fa\u7840\u955c\u50cf\u65f6\uff0c\u6240\u6267\u884c\u7684\u64cd\u4f5c\u6307\u4ee4\u3002<\/p>\n<p>\u4f8b\u5982\uff0cDockerfile \u4f7f\u7528\u5982\u4e0b\u7684\u5185\u5bb9\u521b\u5efa\u4e86\u955c\u50cf\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;image-A<wbr \/>de&gt;\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;[...]\r\nON<wbr \/>BUILD ADD . \/app\/src\r\nON<wbr \/>BUILD RUN \/usr\/local\/bin\/python-build --dir \/app\/src\r\n[...]\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5982\u679c\u57fa\u4e8e image-A \u521b\u5efa\u65b0\u7684\u955c\u50cf\u65f6\uff0c\u65b0\u7684Dockerfile\u4e2d\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;FROM image-A<wbr \/>de&gt;\u6307\u5b9a\u57fa\u7840\u955c\u50cf\u65f6\uff0c\u4f1a\u81ea\u52a8\u6267\u884c<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ON<wbr \/>BUILD<wbr \/>de&gt;\u00a0\u6307\u4ee4\u5185\u5bb9\uff0c\u7b49\u4ef7\u4e8e\u5728\u540e\u9762\u6dfb\u52a0\u4e86\u4e24\u6761\u6307\u4ee4\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;FROM image-A\r\n\r\n#Automatically run the following\r\nADD . \/app\/src\r\nRUN \/usr\/local\/bin\/python-build --dir \/app\/src\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ON<wbr \/>BUILD<wbr \/>de&gt;\u00a0\u6307\u4ee4\u7684\u955c\u50cf\uff0c\u63a8\u8350\u5728\u6807\u7b7e\u4e2d\u6ce8\u660e\uff0c\u4f8b\u5982\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ruby:1.9-on<wbr \/>build<wbr \/>de&gt;\u3002<\/p>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<h2>13.6 Docker \u7f51\u7edc\u5b9e\u73b0<\/h2>\n<p>Docker \u7684\u7f51\u7edc\u5b9e\u73b0\u5176\u5b9e\u5c31\u662f\u5229\u7528\u4e86 Linux \u4e0a\u7684\u7f51\u7edc\u540d\u5b57\u7a7a\u95f4\u548c\u865a\u62df\u7f51\u7edc\u8bbe\u5907\uff08\u7279\u522b\u662f veth pair\uff09\u3002\u5efa\u8bae\u5148\u719f\u6089\u4e86\u89e3\u8fd9\u4e24\u90e8\u5206\u7684\u57fa\u672c\u6982\u5ff5\u518d\u9605\u8bfb\u672c\u7ae0\u3002<\/p>\n<h3>\u57fa\u672c\u539f\u7406<\/h3>\n<p>\u9996\u5148\uff0c\u8981\u5b9e\u73b0\u7f51\u7edc\u901a\u4fe1\uff0c\u673a\u5668\u9700\u8981\u81f3\u5c11\u4e00\u4e2a\u7f51\u7edc\u63a5\u53e3\uff08\u7269\u7406\u63a5\u53e3\u6216\u865a\u62df\u63a5\u53e3\uff09\u6765\u6536\u53d1\u6570\u636e\u5305\uff1b\u6b64\u5916\uff0c\u5982\u679c\u4e0d\u540c\u5b50\u7f51\u4e4b\u95f4\u8981\u8fdb\u884c\u901a\u4fe1\uff0c\u9700\u8981\u8def\u7531\u673a\u5236\u3002<\/p>\n<p>Docker \u4e2d\u7684\u7f51\u7edc\u63a5\u53e3\u9ed8\u8ba4\u90fd\u662f\u865a\u62df\u7684\u63a5\u53e3\u3002\u865a\u62df\u63a5\u53e3\u7684\u4f18\u52bf\u4e4b\u4e00\u662f\u8f6c\u53d1\u6548\u7387\u8f83\u9ad8\u3002 Linux \u901a\u8fc7\u5728\u5185\u6838\u4e2d\u8fdb\u884c\u6570\u636e\u590d\u5236\u6765\u5b9e\u73b0\u865a\u62df\u63a5\u53e3\u4e4b\u95f4\u7684\u6570\u636e\u8f6c\u53d1\uff0c\u53d1\u9001\u63a5\u53e3\u7684\u53d1\u9001\u7f13\u5b58\u4e2d\u7684\u6570\u636e\u5305\u88ab\u76f4\u63a5\u590d\u5236\u5230\u63a5\u6536\u63a5\u53e3\u7684\u63a5\u6536\u7f13\u5b58\u4e2d\u3002\u5bf9\u4e8e\u672c\u5730\u7cfb\u7edf\u548c\u5bb9\u5668\u5185\u7cfb\u7edf\u770b\u6765\u5c31\u50cf\u662f\u4e00\u4e2a\u6b63\u5e38\u7684\u4ee5\u592a\u7f51\u5361\uff0c\u53ea\u662f\u5b83\u4e0d\u9700\u8981\u771f\u6b63\u540c\u5916\u90e8\u7f51\u7edc\u8bbe\u5907\u901a\u4fe1\uff0c\u901f\u5ea6\u8981\u5feb\u5f88\u591a\u3002<\/p>\n<p>Docker \u5bb9\u5668\u7f51\u7edc\u5c31\u5229\u7528\u4e86\u8fd9\u9879\u6280\u672f\u3002\u5b83\u5728\u672c\u5730\u4e3b\u673a\u548c\u5bb9\u5668\u5185\u5206\u522b\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u63a5\u53e3\uff0c\u5e76\u8ba9\u5b83\u4eec\u5f7c\u6b64\u8fde\u901a\uff08\u8fd9\u6837\u7684\u4e00\u5bf9\u63a5\u53e3\u53eb\u505a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;veth pair<wbr \/>de&gt;\uff09\u3002<\/p>\n<h3>\u521b\u5efa\u7f51\u7edc\u53c2\u6570<\/h3>\n<p>Docker \u521b\u5efa\u4e00\u4e2a\u5bb9\u5668\u7684\u65f6\u5019\uff0c\u4f1a\u6267\u884c\u5982\u4e0b\u64cd\u4f5c\uff1a<\/p>\n<ul>\n<li>\u521b\u5efa\u4e00\u5bf9\u865a\u62df\u63a5\u53e3\uff0c\u5206\u522b\u653e\u5230\u672c\u5730\u4e3b\u673a\u548c\u65b0\u5bb9\u5668\u4e2d\uff1b<\/li>\n<li>\u672c\u5730\u4e3b\u673a\u4e00\u7aef\u6865\u63a5\u5230\u9ed8\u8ba4\u7684 docker0 \u6216\u6307\u5b9a\u7f51\u6865\u4e0a\uff0c\u5e76\u5177\u6709\u4e00\u4e2a\u552f\u4e00\u7684\u540d\u5b57\uff0c\u5982 veth65f9\uff1b<\/li>\n<li>\u5bb9\u5668\u4e00\u7aef\u653e\u5230\u65b0\u5bb9\u5668\u4e2d\uff0c\u5e76\u4fee\u6539\u540d\u5b57\u4f5c\u4e3a eth0\uff0c\u8fd9\u4e2a\u63a5\u53e3\u53ea\u5728\u5bb9\u5668\u7684\u540d\u5b57\u7a7a\u95f4\u53ef\u89c1\uff1b<\/li>\n<li>\u4ece\u7f51\u6865\u53ef\u7528\u5730\u5740\u6bb5\u4e2d\u83b7\u53d6\u4e00\u4e2a\u7a7a\u95f2\u5730\u5740\u5206\u914d\u7ed9\u5bb9\u5668\u7684 eth0\uff0c\u5e76\u914d\u7f6e\u9ed8\u8ba4\u8def\u7531\u5230\u6865\u63a5\u7f51\u5361 veth65f9\u3002<\/li>\n<\/ul>\n<p>\u5b8c\u6210\u8fd9\u4e9b\u4e4b\u540e\uff0c\u5bb9\u5668\u5c31\u53ef\u4ee5\u4f7f\u7528 eth0 \u865a\u62df\u7f51\u5361\u6765\u8fde\u63a5\u5176\u4ed6\u5bb9\u5668\u548c\u5176\u4ed6\u7f51\u7edc\u3002<\/p>\n<p>\u53ef\u4ee5\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker run<wbr \/>de&gt;\u00a0\u7684\u65f6\u5019\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net<wbr \/>de&gt;\u00a0\u53c2\u6570\u6765\u6307\u5b9a\u5bb9\u5668\u7684\u7f51\u7edc\u914d\u7f6e\uff0c\u67094\u4e2a\u53ef\u9009\u503c\uff1a<\/p>\n<ul>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net=bridge<wbr \/>de&gt;\u00a0\u8fd9\u4e2a\u662f\u9ed8\u8ba4\u503c\uff0c\u8fde\u63a5\u5230\u9ed8\u8ba4\u7684\u7f51\u6865\u3002<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net=host<wbr \/>de&gt;\u00a0\u544a\u8bc9 Docker \u4e0d\u8981\u5c06\u5bb9\u5668\u7f51\u7edc\u653e\u5230\u9694\u79bb\u7684\u540d\u5b57\u7a7a\u95f4\u4e2d\uff0c\u5373\u4e0d\u8981\u5bb9\u5668\u5316\u5bb9\u5668\u5185\u7684\u7f51\u7edc\u3002\u6b64\u65f6\u5bb9\u5668\u4f7f\u7528\u672c\u5730\u4e3b\u673a\u7684\u7f51\u7edc\uff0c\u5b83\u62e5\u6709\u5b8c\u5168\u7684\u672c\u5730\u4e3b\u673a\u63a5\u53e3\u8bbf\u95ee\u6743\u9650\u3002\u5bb9\u5668\u8fdb\u7a0b\u53ef\u4ee5\u8ddf\u4e3b\u673a\u5176\u5b83 root \u8fdb\u7a0b\u4e00\u6837\u53ef\u4ee5\u6253\u5f00\u4f4e\u8303\u56f4\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u8bbf\u95ee\u672c\u5730\u7f51\u7edc\u670d\u52a1\u6bd4\u5982 D-bus\uff0c\u8fd8\u53ef\u4ee5\u8ba9\u5bb9\u5668\u505a\u4e00\u4e9b\u5f71\u54cd\u6574\u4e2a\u4e3b\u673a\u7cfb\u7edf\u7684\u4e8b\u60c5\uff0c\u6bd4\u5982\u91cd\u542f\u4e3b\u673a\u3002\u56e0\u6b64\u4f7f\u7528\u8fd9\u4e2a\u9009\u9879\u7684\u65f6\u5019\u8981\u975e\u5e38\u5c0f\u5fc3\u3002\u5982\u679c\u8fdb\u4e00\u6b65\u7684\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;privileged=true<wbr \/>de&gt;\uff0c\u5bb9\u5668\u4f1a\u88ab\u5141\u8bb8\u76f4\u63a5\u914d\u7f6e\u4e3b\u673a\u7684\u7f51\u7edc\u5806\u6808\u3002<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net=container:NAME_or_ID<wbr \/>de&gt;\u00a0\u8ba9 Docker \u5c06\u65b0\u5efa\u5bb9\u5668\u7684\u8fdb\u7a0b\u653e\u5230\u4e00\u4e2a\u5df2\u5b58\u5728\u5bb9\u5668\u7684\u7f51\u7edc\u6808\u4e2d\uff0c\u65b0\u5bb9\u5668\u8fdb\u7a0b\u6709\u81ea\u5df1\u7684\u6587\u4ef6\u7cfb\u7edf\u3001\u8fdb\u7a0b\u5217\u8868\u548c\u8d44\u6e90\u9650\u5236\uff0c\u4f46\u4f1a\u548c\u5df2\u5b58\u5728\u7684\u5bb9\u5668\u5171\u4eab IP \u5730\u5740\u548c\u7aef\u53e3\u7b49\u7f51\u7edc\u8d44\u6e90\uff0c\u4e24\u8005\u8fdb\u7a0b\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;lo<wbr \/>de&gt;\u00a0\u73af\u56de\u63a5\u53e3\u901a\u4fe1\u3002<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net=none<wbr \/>de&gt;\u00a0\u8ba9 Docker \u5c06\u65b0\u5bb9\u5668\u653e\u5230\u9694\u79bb\u7684\u7f51\u7edc\u6808\u4e2d\uff0c\u4f46\u662f\u4e0d\u8fdb\u884c\u7f51\u7edc\u914d\u7f6e\u3002\u4e4b\u540e\uff0c\u7528\u6237\u53ef\u4ee5\u81ea\u5df1\u8fdb\u884c\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<h3>\u7f51\u7edc\u914d\u7f6e\u7ec6\u8282<\/h3>\n<p>\u7528\u6237\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net=none<wbr \/>de&gt;\u00a0\u540e\uff0c\u53ef\u4ee5\u81ea\u884c\u914d\u7f6e\u7f51\u7edc\uff0c\u8ba9\u5bb9\u5668\u8fbe\u5230\u8ddf\u5e73\u5e38\u4e00\u6837\u5177\u6709\u8bbf\u95ee\u7f51\u7edc\u7684\u6743\u9650\u3002\u901a\u8fc7\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u4e86\u89e3 Docker \u914d\u7f6e\u7f51\u7edc\u7684\u7ec6\u8282\u3002<\/p>\n<p>\u9996\u5148\uff0c\u542f\u52a8\u4e00\u4e2a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/bin\/bash<wbr \/>de&gt;\u00a0\u5bb9\u5668\uff0c\u6307\u5b9a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;net=none<wbr \/>de&gt;\u00a0\u53c2\u6570\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run -i -t --rm --net=none base \/bin\/bash\r\nroot@63f36fc01b5f:\/#\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5728\u672c\u5730\u4e3b\u673a\u67e5\u627e\u5bb9\u5668\u7684\u8fdb\u7a0b id\uff0c\u5e76\u4e3a\u5b83\u521b\u5efa\u7f51\u7edc\u547d\u540d\u7a7a\u95f4\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker inspect -f '{{.State.Pid}}' 63f36fc01b5f\r\n2778\r\n$ pid=2778\r\n$ sudo mkdir -p \/var\/run\/netns\r\n$ sudo ln -s \/proc\/$pid\/ns\/net \/var\/run\/netns\/$pid\r\n<wbr \/>de&gt;<\/pre>\n<p>\u68c0\u67e5\u6865\u63a5\u7f51\u5361\u7684 IP \u548c\u5b50\u7f51\u63a9\u7801\u4fe1\u606f\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ ip addr show docker0\r\n21: docker0: ...\r\ninet 172.17.42.1\/16 scope global docker0\r\n...\r\n<wbr \/>de&gt;<\/pre>\n<p>\u521b\u5efa\u4e00\u5bf9 \u201cveth pair\u201d \u63a5\u53e3 A \u548c B\uff0c\u7ed1\u5b9a A \u5230\u7f51\u6865\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker0<wbr \/>de&gt;\uff0c\u5e76\u542f\u7528\u5b83<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo ip link add A type veth peer name B\r\n$ sudo brctl addif docker0 A\r\n$ sudo ip link set A up\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5c06B\u653e\u5230\u5bb9\u5668\u7684\u7f51\u7edc\u547d\u540d\u7a7a\u95f4\uff0c\u547d\u540d\u4e3a eth0\uff0c\u542f\u52a8\u5b83\u5e76\u914d\u7f6e\u4e00\u4e2a\u53ef\u7528 IP\uff08\u6865\u63a5\u7f51\u6bb5\uff09\u548c\u9ed8\u8ba4\u7f51\u5173\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo ip link set B netns $pid\r\n$ sudo ip netns exec $pid ip link set dev B name eth0\r\n$ sudo ip netns exec $pid ip link set eth0 up\r\n$ sudo ip netns exec $pid ip addr add 172.17.42.99\/16 dev eth0\r\n$ sudo ip netns exec $pid ip route add default via 172.17.42.1\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4ee5\u4e0a\uff0c\u5c31\u662f Docker \u914d\u7f6e\u7f51\u7edc\u7684\u5177\u4f53\u8fc7\u7a0b\u3002<\/p>\n<p>\u5f53\u5bb9\u5668\u7ed3\u675f\u540e\uff0cDocker \u4f1a\u6e05\u7a7a\u5bb9\u5668\uff0c\u5bb9\u5668\u5185\u7684 eth0 \u4f1a\u968f\u7f51\u7edc\u547d\u540d\u7a7a\u95f4\u4e00\u8d77\u88ab\u6e05\u9664\uff0cA \u63a5\u53e3\u4e5f\u88ab\u81ea\u52a8\u4ece<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker0<wbr \/>de&gt;\u00a0\u5378\u8f7d\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;ip netns exec<wbr \/>de&gt;\u00a0\u547d\u4ee4\u6765\u5728\u6307\u5b9a\u7f51\u7edc\u540d\u5b57\u7a7a\u95f4\u4e2d\u8fdb\u884c\u914d\u7f6e\uff0c\u4ece\u800c\u914d\u7f6e\u5bb9\u5668\u5185\u7684\u7f51\u7edc\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h1>14. \u9644\u5f55\u4e00\u3001Docker\u547d\u4ee4\u67e5\u8be2<\/h1>\n<h2>\u57fa\u672c\u8bed\u6cd5<\/h2>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker [OPTIONS] COMMAND [arg...]\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4e00\u822c\u6765\u8bf4\uff0cDocker \u547d\u4ee4\u53ef\u4ee5\u7528\u6765\u7ba1\u7406 daemon\uff0c\u6216\u8005\u901a\u8fc7 CLI \u547d\u4ee4\u7ba1\u7406\u955c\u50cf\u548c\u5bb9\u5668\u3002\u53ef\u4ee5\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;man docker<wbr \/>de&gt;\u6765\u67e5\u770b\u8fd9\u4e9b\u547d\u4ee4\u3002<\/p>\n<h2>\u9009\u9879<\/h2>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;-D=true|false\r\n    \u4f7f\u7528 debug \u6a21\u5f0f\u3002\u9ed8\u8ba4\u4e3a false\u3002\r\n\r\n-H, --host=[unix:\/\/\/var\/run\/docker.sock]: tcp:\/\/[host:port]\u6765\u7ed1\u5b9a\u6216\u8005 unix:\/\/[\/path\/to\/socket] \u6765\u4f7f\u7528\u3002\r\n    \u5728 daemon \u6a21\u5f0f\u4e0b\u7ed1\u5b9a\u7684 socket\uff0c\u901a\u8fc7\u4e00\u4e2a\u6216\u591a\u4e2a tcp:\/\/host:port, unix:\/\/\/path\/to\/socket, fd:\/\/* or fd:\/\/socketfd \u6765\u6307\u5b9a\u3002\r\n\r\n--api-enable-cors=true|false\r\n    \u5728\u8fdc\u7aef API \u4e2d\u542f\u7528 CORS \u5934\u3002\u7f3a\u7701\u4e3a false\u3002\r\n\r\n-b=\"\"\r\n    \u5c06\u5bb9\u5668\u6302\u8f7d\u5230\u4e00\u4e2a\u5df2\u5b58\u5728\u7684\u7f51\u6865\u4e0a\u3002\u6307\u5b9a\u4e3a 'none' \u65f6\u5219\u7981\u7528\u5bb9\u5668\u7684\u7f51\u7edc\u3002\r\n\r\n--bip=\"\"\r\n    \u8ba9\u52a8\u6001\u521b\u5efa\u7684 docker0 \u91c7\u7528\u7ed9\u5b9a\u7684 CIDR \u5730\u5740; \u4e0e -b \u9009\u9879\u4e92\u65a5\u3002\r\n\r\n-d=true|false\r\n    \u4f7f\u7528 daemon \u6a21\u5f0f\u3002\u7f3a\u7701\u4e3a false\u3002\r\n\r\n--dns=\"\"\r\n    \u8ba9 Docker \u4f7f\u7528\u7ed9\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002\r\n\r\n-g=\"\"\r\n    \u6307\u5b9a Docker \u8fd0\u884c\u65f6\u7684 root \u8def\u5f84\u3002\u7f3a\u7701\u4e3a \/var\/lib\/docker\u3002\r\n\r\n--icc=true|false\r\n    \u542f\u7528\u5bb9\u5668\u95f4\u901a\u4fe1\u3002\u9ed8\u8ba4\u4e3a true\u3002\r\n\r\n--ip=\"\"\r\n    \u7ed1\u5b9a\u7aef\u53e3\u65f6\u5019\u7684\u9ed8\u8ba4 IP \u5730\u5740\u3002\u7f3a\u7701\u4e3a 0.0.0.0\u3002\r\n\r\n--iptables=true|false\r\n    \u7981\u6b62 Docker \u6dfb\u52a0 iptables \u89c4\u5219\u3002\u7f3a\u7701\u4e3a true\u3002\r\n\r\n--mtu=VALUE\r\n    \u6307\u5b9a\u5bb9\u5668\u7f51\u7edc\u7684 mtu\u3002\u7f3a\u7701\u4e3a 1500\u3002\r\n\r\n-p=\"\"\r\n    \u6307\u5b9a daemon \u7684 PID \u6587\u4ef6\u8def\u5f84\u3002\u7f3a\u7701\u4e3a \/var\/run\/docker.pid\u3002\r\n\r\n-s=\"\"\r\n    \u5f3a\u5236 Docker \u8fd0\u884c\u65f6\u4f7f\u7528\u7ed9\u5b9a\u7684\u5b58\u50a8\u9a71\u52a8\u3002\r\n\r\n-v=true|false\r\n    \u8f93\u51fa\u7248\u672c\u4fe1\u606f\u5e76\u9000\u51fa\u3002\u7f3a\u7701\u503c\u4e3a false\u3002\r\n\r\n--selinux-enabled=true|false\r\n    \u542f\u7528 SELinux \u652f\u6301\u3002\u7f3a\u7701\u503c\u4e3a false\u3002SELinux \u76ee\u524d\u4e0d\u652f\u6301 BTRFS \u5b58\u50a8\u9a71\u52a8\u3002\r\n<wbr \/>de&gt;<\/pre>\n<h2>\u547d\u4ee4<\/h2>\n<p>Docker \u7684\u547d\u4ee4\u53ef\u4ee5\u91c7\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker-CMD<wbr \/>de&gt;\u00a0\u6216\u8005\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;docker CMD<wbr \/>de&gt;\u00a0\u7684\u65b9\u5f0f\u6267\u884c\u3002\u4e24\u8005\u4e00\u81f4\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker-attach(1)\r\n    \u4f9d\u9644\u5230\u4e00\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\u4e2d\u3002\r\n\r\ndocker-build(1)\r\n    \u4ece\u4e00\u4e2a Dockerfile \u521b\u5efa\u4e00\u4e2a\u955c\u50cf\r\n\r\ndocker-commit(1)\r\n    \u4ece\u4e00\u4e2a\u5bb9\u5668\u7684\u4fee\u6539\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u955c\u50cf\r\n\r\ndocker-cp(1)\r\n    \u4ece\u5bb9\u5668\u4e2d\u590d\u5236\u6587\u4ef6\u5230\u5bbf\u4e3b\u7cfb\u7edf\u4e2d\r\n\r\ndocker-diff(1)\r\n    \u68c0\u67e5\u4e00\u4e2a\u5bb9\u5668\u6587\u4ef6\u7cfb\u7edf\u7684\u4fee\u6539\r\n\r\ndocker-events(1)\r\n    \u4ece\u670d\u52a1\u7aef\u83b7\u53d6\u5b9e\u65f6\u7684\u4e8b\u4ef6\r\n\r\ndocker-export(1)\r\n    \u5bfc\u51fa\u5bb9\u5668\u5185\u5bb9\u4e3a\u4e00\u4e2a tar \u5305\r\n\r\ndocker-history(1)\r\n    \u663e\u793a\u4e00\u4e2a\u955c\u50cf\u7684\u5386\u53f2\r\n\r\ndocker-images(1)\r\n    \u5217\u51fa\u5b58\u5728\u7684\u955c\u50cf\r\n\r\ndocker-imp<wbr \/>ort(1)\r\n    \u5bfc\u5165\u4e00\u4e2a\u6587\u4ef6\uff08\u5178\u578b\u4e3a tar \u5305\uff09\u8def\u5f84\u6216\u76ee\u5f55\u6765\u521b\u5efa\u4e00\u4e2a\u955c\u50cf\r\n\r\ndocker-info(1)\r\n    \u663e\u793a\u4e00\u4e9b\u76f8\u5173\u7684\u7cfb\u7edf\u4fe1\u606f\r\n\r\ndocker-inspect(1)\r\n    \u663e\u793a\u4e00\u4e2a\u5bb9\u5668\u7684\u5e95\u5c42\u5177\u4f53\u4fe1\u606f\u3002\r\n\r\ndocker-kill(1)\r\n    \u5173\u95ed\u4e00\u4e2a\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668 (\u5305\u62ec\u8fdb\u7a0b\u548c\u6240\u6709\u8d44\u6e90)\r\n\r\ndocker-load(1)\r\n    \u4ece\u4e00\u4e2a tar \u5305\u4e2d\u52a0\u8f7d\u4e00\u4e2a\u955c\u50cf\r\n\r\ndocker-login(1)\r\n    \u6ce8\u518c\u6216\u767b\u5f55\u5230\u4e00\u4e2a Docker \u7684\u4ed3\u5e93\u670d\u52a1\u5668\r\n\r\ndocker-logout(1)\r\n    \u4ece Docker \u7684\u4ed3\u5e93\u670d\u52a1\u5668\u767b\u51fa\r\n\r\ndocker-logs(1)\r\n    \u83b7\u53d6\u5bb9\u5668\u7684 log \u4fe1\u606f\r\n\r\ndocker-pause(1)\r\n    \u6682\u505c\u4e00\u4e2a\u5bb9\u5668\u4e2d\u7684\u6240\u6709\u8fdb\u7a0b\r\n\r\ndocker-port(1)\r\n    \u67e5\u627e\u4e00\u4e2a nat \u5230\u4e00\u4e2a\u79c1\u6709\u7f51\u53e3\u7684\u516c\u5171\u53e3\r\n\r\ndocker-ps(1)\r\n    \u5217\u51fa\u5bb9\u5668\r\n\r\ndocker-pull(1)\r\n    \u4ece\u4e00\u4e2aDocker\u7684\u4ed3\u5e93\u670d\u52a1\u5668\u4e0b\u62c9\u4e00\u4e2a\u955c\u50cf\u6216\u4ed3\u5e93\r\n\r\ndocker-push(1)\r\n    \u5c06\u4e00\u4e2a\u955c\u50cf\u6216\u8005\u4ed3\u5e93\u63a8\u9001\u5230\u4e00\u4e2a Docker \u7684\u6ce8\u518c\u670d\u52a1\u5668\r\n\r\ndocker-restart(1)\r\n    \u91cd\u542f\u4e00\u4e2a\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\r\n\r\ndocker-rm(1)\r\n    \u5220\u9664\u7ed9\u5b9a\u7684\u82e5\u5e72\u4e2a\u5bb9\u5668\r\n\r\ndocker-rmi(1)\r\n    \u5220\u9664\u7ed9\u5b9a\u7684\u82e5\u5e72\u4e2a\u955c\u50cf\r\n\r\ndocker-run(1)\r\n    \u521b\u5efa\u4e00\u4e2a\u65b0\u5bb9\u5668\uff0c\u5e76\u5728\u5176\u4e2d\u8fd0\u884c\u7ed9\u5b9a\u547d\u4ee4\r\n\r\ndocker-save(1)\r\n    \u4fdd\u5b58\u4e00\u4e2a\u955c\u50cf\u4e3a tar \u5305\u6587\u4ef6\r\n\r\ndocker-search(1)\r\n    \u5728 Docker index \u4e2d\u641c\u7d22\u4e00\u4e2a\u955c\u50cf\r\n\r\ndocker-start(1)\r\n    \u542f\u52a8\u4e00\u4e2a\u5bb9\u5668\r\n\r\ndocker-stop(1)\r\n    \u7ec8\u6b62\u4e00\u4e2a\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\r\n\r\ndocker-tag(1)\r\n    \u4e3a\u4e00\u4e2a\u955c\u50cf\u6253\u6807\u7b7e\r\n\r\ndocker-top(1)\r\n    \u67e5\u770b\u4e00\u4e2a\u5bb9\u5668\u4e2d\u7684\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u4fe1\u606f\r\n\r\ndocker-unpause(1)\r\n    \u5c06\u4e00\u4e2a\u5bb9\u5668\u5185\u6240\u6709\u7684\u8fdb\u7a0b\u4ece\u6682\u505c\u72b6\u6001\u4e2d\u6062\u590d\r\n\r\ndocker-version(1)\r\n    \u8f93\u51fa Docker \u7684\u7248\u672c\u4fe1\u606f\r\n\r\ndocker-wait(1)\r\n    \u963b\u585e\u76f4\u5230\u4e00\u4e2a\u5bb9\u5668\u7ec8\u6b62\uff0c\u7136\u540e\u8f93\u51fa\u5b83\u7684\u9000\u51fa\u7b26\r\n<wbr \/>de&gt;<\/pre>\n<h2>\u4e00\u5f20\u56fe\u603b\u7ed3 Docker \u7684\u547d\u4ee4<\/h2>\n<\/div>\n<div><\/div>\n<div>\n<h1>15. \u9644\u5f55\u4e8c\u3001\u5e38\u89c1\u4ed3\u5e93\u4ecb\u7ecd<\/h1>\n<p>\u672c\u7ae0\u5c06\u4ecb\u7ecd\u5e38\u89c1\u7684\u4e00\u4e9b\u4ed3\u5e93\u548c\u955c\u50cf\u7684\u529f\u80fd\uff0c\u4f7f\u7528\u65b9\u6cd5\u548c\u751f\u6210\u5b83\u4eec\u7684 Dockerfile \u7b49\u3002\u5305\u62ec Ubuntu\u3001CentOS\u3001MySQL\u3001MongoDB\u3001Redis\u3001Nginx\u3001Wordpress\u3001Node.js \u7b49\u3002<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.1.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/ubuntu\/\" target=\"_blank\" rel=\"nofollow noopener\">Ubuntu<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Ubuntu\" target=\"_blank\" rel=\"nofollow noopener\">Ubuntu<\/a>\u00a0\u662f\u6d41\u884c\u7684 Linux \u53d1\u884c\u7248\uff0c\u5176\u81ea\u5e26\u8f6f\u4ef6\u7248\u672c\u5f80\u5f80\u8f83\u65b0\u4e00\u4e9b\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 Ubuntu\u4ece12.04 ~ 14.10 \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u9ed8\u8ba4\u4f1a\u542f\u52a8\u4e00\u4e2a\u6700\u5c0f\u5316\u7684 Ubuntu \u73af\u5883\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-ubuntu -i -t ubuntu\r\nroot@523c70904d54:\/#\r\n<wbr \/>de&gt;<\/pre>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/tianon\/docker-brew-ubuntu-core\/blob\/2b105575647a7e2030ff344d427c3920b89e17a9\/precise\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">12.04 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/tianon\/docker-brew-ubuntu-core\/blob\/2b105575647a7e2030ff344d427c3920b89e17a9\/trusty\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">14.04 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/tianon\/docker-brew-ubuntu-core\/blob\/2b105575647a7e2030ff344d427c3920b89e17a9\/utopic\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">14.10 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.2.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/centos\/\" target=\"_blank\" rel=\"nofollow noopener\">CentOS<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/CentOS\" target=\"_blank\" rel=\"nofollow noopener\">CentOS<\/a>\u00a0\u662f\u6d41\u884c\u7684 Linux \u53d1\u884c\u7248\uff0c\u5176\u8f6f\u4ef6\u5305\u5927\u591a\u8ddf RedHat \u7cfb\u5217\u4fdd\u6301\u4e00\u81f4\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 CentOS \u4ece 5 ~ 7 \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u9ed8\u8ba4\u4f1a\u542f\u52a8\u4e00\u4e2a\u6700\u5c0f\u5316\u7684 CentOS \u73af\u5883\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-centos -i -t centos bash\r\nbash-4.2#\r\n<wbr \/>de&gt;<\/pre>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/CentOS\/sig-cloud-instance-images\/blob\/2e5a9c4e8b7191b393822e4b9e98820db5638a77\/docker\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">CentOS 5 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/CentOS\/sig-cloud-instance-images\/blob\/8717e33ea5432ecb33d7ecefe8452a973715d037\/docker\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">CentOS 6 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/CentOS\/sig-cloud-instance-images\/blob\/af7a1b9f8f30744360a10fe44c53a1591bef26f9\/docker\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">CentOS 7 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.3.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/mysql\/\" target=\"_blank\" rel=\"nofollow noopener\">MySQL<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/MySQL\" target=\"_blank\" rel=\"nofollow noopener\">MySQL<\/a>\u00a0\u662f\u5f00\u6e90\u7684\u5173\u7cfb\u6570\u636e\u5e93\u5b9e\u73b0\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 MySQL \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\uff0c\u5305\u62ec 5.6 \u7cfb\u5217\u30015.7 \u7cfb\u5217\u7b49\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u9ed8\u8ba4\u4f1a\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;3306<wbr \/>de&gt;\u00a0\u7aef\u53e3\u542f\u52a8\u6570\u636e\u5e93\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528\u5176\u5b83\u5e94\u7528\u6765\u8fde\u63a5\u5230\u8be5\u5bb9\u5668\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-app --link some-mysql:mysql -d application-that-uses-mysql\r\n<wbr \/>de&gt;<\/pre>\n<p>\u6216\u8005\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;mysql<wbr \/>de&gt;\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run -it --link some-mysql:mysql --rm mysql sh -c 'exec mysql -h\"$MYSQL_PORT_3306_TCP_ADDR\" -P\"$MYSQL_PORT_3306_TCP_PORT\" -uroot -p\"$MYSQL_ENV_MYSQL_ROOT_PASSWORD\"'\r\n<wbr \/>de&gt;<\/pre>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/docker-library\/mysql\/blob\/7461a52b43f06839a4d8723ae8841f4cb616b3d0\/5.6\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">5.6 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/mysql\/blob\/7461a52b43f06839a4d8723ae8841f4cb616b3d0\/5.7\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">5.7 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.4.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/mongo\/\" target=\"_blank\" rel=\"nofollow noopener\">MongoDB<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/MongoDB\" target=\"_blank\" rel=\"nofollow noopener\">MongoDB<\/a>\u00a0\u662f\u5f00\u6e90\u7684 NoSQL \u6570\u636e\u5e93\u5b9e\u73b0\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 MongoDB 2.2 ~ 2.7 \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u9ed8\u8ba4\u4f1a\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;27017<wbr \/>de&gt;\u00a0\u7aef\u53e3\u542f\u52a8\u6570\u636e\u5e93\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-mongo -d mongo\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4f7f\u7528\u5176\u4ed6\u5e94\u7528\u8fde\u63a5\u5230\u5bb9\u5668\uff0c\u53ef\u4ee5\u7528<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-app --link some-mongo:mongo -d application-that-uses-mongo\r\n<wbr \/>de&gt;<\/pre>\n<p>\u6216\u8005\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;mongo<wbr \/>de&gt;<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run -it --link some-mongo:mongo --rm mongo sh -c 'exec mongo \"$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT\/test\"'\r\n<wbr \/>de&gt;<\/pre>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/docker-library\/mongo\/blob\/77c841472ccb6cc87fea1218269d097405edc6cb\/2.2\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">2.2 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/mongo\/blob\/807078cb7b5f0289f6dabf9f6875d5318122bc30\/2.4\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">2.4 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/mongo\/blob\/77c841472ccb6cc87fea1218269d097405edc6cb\/2.6\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">2.6 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/mongo\/blob\/807078cb7b5f0289f6dabf9f6875d5318122bc30\/2.7\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">2.7 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.5.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/redis\/\" target=\"_blank\" rel=\"nofollow noopener\">Redis<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Redis\" target=\"_blank\" rel=\"nofollow noopener\">Redis<\/a>\u00a0\u662f\u5f00\u6e90\u7684\u5185\u5b58 Key-Value \u6570\u636e\u5e93\u5b9e\u73b0\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 Redis 2.6 ~ 2.8.9 \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u9ed8\u8ba4\u4f1a\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;6379<wbr \/>de&gt;\u00a0\u7aef\u53e3\u542f\u52a8\u6570\u636e\u5e93\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-redis -d redis\r\n<wbr \/>de&gt;<\/pre>\n<p>\u53e6\u5916\u8fd8\u53ef\u4ee5\u542f\u7528\u00a0<a href=\"http:\/\/redis.io\/topics\/persistence\" target=\"_blank\" rel=\"nofollow noopener\">\u6301\u4e45\u5b58\u50a8<\/a>\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-redis -d redis redis-server --appendonly yes\r\n<wbr \/>de&gt;<\/pre>\n<p>\u9ed8\u8ba4\u6570\u636e\u5b58\u50a8\u4f4d\u7f6e\u5728\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;VOLUME\/da<wbr \/>ta<wbr \/>de&gt;\u3002\u53ef\u4ee5\u4f7f\u7528\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;&#8211;volumes-from some-volume-container<wbr \/>de&gt;\u00a0\u6216\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-v \/docker\/host\/dir:\/da<wbr \/>ta<wbr \/>de&gt;\u00a0\u5c06\u6570\u636e\u5b58\u653e\u5230\u672c\u5730\u3002<\/p>\n<p>\u4f7f\u7528\u5176\u4ed6\u5e94\u7528\u8fde\u63a5\u5230\u5bb9\u5668\uff0c\u53ef\u4ee5\u7528<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-app --link some-redis:redis -d application-that-uses-redis\r\n<wbr \/>de&gt;<\/pre>\n<p>\u6216\u8005\u901a\u8fc7\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;redis-cli<wbr \/>de&gt;<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run -it --link some-redis:redis --rm redis sh -c 'exec redis-cli -h \"$REDIS_PORT_6379_TCP_ADDR\" -p \"$REDIS_PORT_6379_TCP_PORT\"'\r\n<wbr \/>de&gt;<\/pre>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/docker-library\/redis\/blob\/02d9cd887a4e0d50db4bb085eab7235115a6fe4a\/2.6.17\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">2.6 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/redis\/blob\/d0665bb1bbddd4cc035dbc1fc774695fa534d648\/2.8.13\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">\u6700\u65b0 2.8 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.6.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/nginx\/\" target=\"_blank\" rel=\"nofollow noopener\">Nginx<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Nginx\" target=\"_blank\" rel=\"nofollow noopener\">Nginx<\/a>\u00a0\u662f\u5f00\u6e90\u7684\u9ad8\u6548\u7684 Web \u670d\u52a1\u5668\u5b9e\u73b0\uff0c\u652f\u6301 HTTP\u3001HTTPS\u3001SMTP\u3001POP3\u3001IMAP \u7b49\u534f\u8bae\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 Nginx 1.0 ~ 1.7 \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u4f5c\u4e3a\u4e00\u4e2a\u9759\u6001\u9875\u9762\u670d\u52a1\u5668\u542f\u52a8\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-nginx -v \/some\/content:\/usr\/share\/nginx\/html:ro -d nginx\r\n<wbr \/>de&gt;<\/pre>\n<p>\u7528\u6237\u4e5f\u53ef\u4ee5\u4e0d\u4f7f\u7528\u8fd9\u79cd\u6620\u5c04\u65b9\u5f0f\uff0c\u901a\u8fc7\u5229\u7528 Dockerfile \u6765\u76f4\u63a5\u5c06\u9759\u6001\u9875\u9762\u5185\u5bb9\u653e\u5230\u955c\u50cf\u4e2d\uff0c\u5185\u5bb9\u4e3a<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;FROM nginx\r\nCOPY static-html-directory \/usr\/share\/nginx\/html\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4e4b\u540e\u751f\u6210\u65b0\u7684\u955c\u50cf\uff0c\u5e76\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker build -t some-content-nginx .\r\n$ sudo docker run --name some-nginx -d some-content-nginx\r\n<wbr \/>de&gt;<\/pre>\n<p>\u5f00\u653e\u7aef\u53e3\uff0c\u5e76\u6620\u5c04\u5230\u672c\u5730\u7684\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;8080<wbr \/>de&gt;\u00a0\u7aef\u53e3\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;sudo docker run --name some-nginx -d -p 8080:80 some-content-nginx\r\n<wbr \/>de&gt;<\/pre>\n<p>Nginx\u7684\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;\/etc\/nginx\/nginx.conf<wbr \/>de&gt;\uff0c\u53ef\u4ee5\u901a\u8fc7\u6620\u5c04\u5b83\u6765\u4f7f\u7528\u672c\u5730\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f8b\u5982<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;docker run --name some-nginx -v \/some\/nginx.conf:\/etc\/nginx\/nginx.conf:ro -d nginx\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u65f6\uff0c\u4e3a\u4e86\u5728\u5bb9\u5668\u4e2d\u6b63\u5e38\u8fd0\u884c\uff0c\u9700\u8981\u4fdd\u6301\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;daemon off;<wbr \/>de&gt;\u3002<\/p>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/nginxinc\/docker-nginx\/blob\/3713a0157083eb4776e71f5a5aef4b2a5bc03ab1\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">1 ~ 1.7 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.7.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/wordpress\/\" target=\"_blank\" rel=\"nofollow noopener\">WordPress<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/WordPress\" target=\"_blank\" rel=\"nofollow noopener\">WordPress<\/a>\u00a0\u662f\u5f00\u6e90\u7684 Blog \u548c\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\u6846\u67b6\uff0c\u5b83\u57fa\u4e8e PhP \u548c MySQL\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 WordPress 4.0 \u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u542f\u52a8\u5bb9\u5668\u9700\u8981 MySQL \u7684\u652f\u6301\uff0c\u9ed8\u8ba4\u7aef\u53e3\u4e3a\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;80<wbr \/>de&gt;\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run --name some-wordpress --link some-mysql:mysql -d wordpress\r\n<wbr \/>de&gt;<\/pre>\n<p>\u542f\u52a8 WordPress \u5bb9\u5668\u65f6\u53ef\u4ee5\u6307\u5b9a\u7684\u4e00\u4e9b\u73af\u5883\u53c2\u6570\u5305\u62ec<\/p>\n<ul>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_DB_USER=&#8230;<wbr \/>de&gt;\u00a0\u7f3a\u7701\u4e3a \u201croot\u201d<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_DB_PASSWORD=&#8230;<wbr \/>de&gt;\u00a0\u7f3a\u7701\u4e3a\u8fde\u63a5 mysql \u5bb9\u5668\u7684\u73af\u5883\u53d8\u91cf\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;MYSQL_ROOT_PASSWORD<wbr \/>de&gt;\u00a0\u7684\u503c<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_DB_NAME=&#8230;<wbr \/>de&gt;\u00a0\u7f3a\u7701\u4e3a \u201cwordpress\u201d<\/li>\n<li><wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_AUTH_KEY=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_SECURE_AUTH_KEY=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_LOGGED_IN_KEY=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_NONCE_KEY=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_AUTH_SALT=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_SECURE_AUTH_SALT=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_LOGGED_IN_SALT=&#8230;<wbr \/>de&gt;,\u00a0<wbr \/>de style=&#8221;box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, &#8216;Liberation Mono&#8217;, Menlo, Courier, monospace; font-size: 14px; padding: 0.2em 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247);&#8221; &gt;-e WORDPRESS_NONCE_SALT=&#8230;<wbr \/>de&gt;\u00a0\u7f3a\u7701\u4e3a\u968f\u673a sha1 \u4e32<\/li>\n<\/ul>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/docker-library\/wordpress\/blob\/aee00669e7c43f435f021cb02871bffd63d5677a\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">4.0 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h2>15.8.\u00a0<a href=\"https:\/\/registry.hub.docker.com\/_\/node\/\" target=\"_blank\" rel=\"nofollow noopener\">Node.js<\/a><\/h2>\n<h3>\u57fa\u672c\u4fe1\u606f<\/h3>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Node.js\" target=\"_blank\" rel=\"nofollow noopener\">Node.js<\/a>\u662f\u57fa\u4e8e JavaS<wbr \/>cript \u7684\u53ef\u6269\u5c55\u670d\u52a1\u7aef\u548c\u7f51\u7edc\u8f6f\u4ef6\u5f00\u53d1\u5e73\u53f0\u3002 \u8be5\u4ed3\u5e93\u63d0\u4f9b\u4e86 Node.js 0.8 ~ 0.11 \u5404\u4e2a\u7248\u672c\u7684\u955c\u50cf\u3002<\/p>\n<h3>\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u5728\u9879\u76ee\u4e2d\u521b\u5efa\u4e00\u4e2a Dockerfile\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;FROM node:0.10-on<wbr \/>build\r\n# replace this with your application's default port\r\nEXPOSE 8888\r\n<wbr \/>de&gt;<\/pre>\n<p>\u7136\u540e\u521b\u5efa\u955c\u50cf\uff0c\u5e76\u542f\u52a8\u5bb9\u5668<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker build -t my-nodejs-app\r\n$ sudo docker run -it --rm --name my-running-app my-nodejs-app\r\n<wbr \/>de&gt;<\/pre>\n<p>\u4e5f\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u4e00\u4e2a\u7b80\u5355\u5bb9\u5668\u3002<\/p>\n<pre><wbr \/>de style=\"box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; white-space: pre; border: 0px; display: inline; line-height: inherit; word-wrap: normal; background-color: transparent;\"  &gt;$ sudo docker run -it --rm --name my-running-script -v \"$(pwd)\":\/usr\/src\/myapp -w \/usr\/src\/myapp node:0.10 node your-daemon-or-script.js\r\n<wbr \/>de&gt;<\/pre>\n<h3>Dockerfile<\/h3>\n<ul>\n<li><a href=\"https:\/\/github.com\/docker-library\/node\/blob\/d017d679e92e84a810c580cdb29fcdbba23c2bb9\/0.8\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">0.8 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/node\/blob\/913a225f2fda34d6a811fac1466e4f09f075fcf6\/0.10\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">0.10 \u7248\u672c<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/docker-library\/node\/blob\/d017d679e92e84a810c580cdb29fcdbba23c2bb9\/0.11\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">0.11 \u7248\u672c<\/a><\/li>\n<\/ul>\n<\/div>\n<div><\/div>\n<div>\n<h1>16. \u9644\u5f55\u4e09\u3001\u8d44\u6e90\u94fe\u63a5<\/h1>\n<ul>\n<li>Docker \u4e3b\u7ad9\u70b9:\u00a0<a href=\"https:\/\/www.docker.io\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/www.docker.io<\/a><\/li>\n<li>Docker \u6ce8\u518c\u4e2d\u5fc3API:\u00a0<a href=\"http:\/\/docs.docker.com\/reference\/api\/registry_api\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/docs.docker.com\/reference\/api\/registry_api\/<\/a><\/li>\n<li>Docker Hub API:\u00a0<a href=\"http:\/\/docs.docker.com\/reference\/api\/docker-io_api\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/docs.docker.com\/reference\/api\/docker-io_api\/<\/a><\/li>\n<li>Docker \u8fdc\u7aef\u5e94\u7528API:\u00a0<a href=\"http:\/\/docs.docker.com\/reference\/api\/docker_remote_api\/\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/docs.docker.com\/reference\/api\/docker_remote_api\/<\/a><\/li>\n<li>Dockerfile \u53c2\u8003\uff1a<a href=\"https:\/\/docs.docker.com\/reference\/builder\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/docs.docker.com\/reference\/builder\/<\/a><\/li>\n<li>Dockerfile \u6700\u4f73\u5b9e\u8df5\uff1a<a href=\"https:\/\/docs.docker.com\/articles\/dockerfile_best-practices\/\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/docs.docker.com\/articles\/dockerfile_best-practices\/<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>10. \u5b9e\u6218\u6848\u4f8b \u4ecb\u7ecd\u4e00\u4e9b\u5178\u578b\u7684\u5e94\u7528\u573a\u666f\u548c\u6848\u4f8b\u3002 10.1. \u4f7f\u7528 Supervisor \u6765\u7ba1\u7406\u8fdb\u7a0b Dock &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[306,308,294,305,307,304,309,229,295],"class_list":["post-379","post","type-post","status-publish","format-standard","hentry","category-4","tag-cgroup","tag-container","tag-docker","tag-dockerfile","tag-namespace","tag-supervisor","tag-unionfs","tag-229","tag-295"],"views":1848,"_links":{"self":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=379"}],"version-history":[{"count":1,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/379\/revisions"}],"predecessor-version":[{"id":380,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/379\/revisions\/380"}],"wp:attachment":[{"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-shu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}