In the previous chapter, we talked about the most basic composition of dockerfile, said two kinds of dockerfile construction image method, this one, we will introduce the dockerfile inside the n many parameters.
Here's what we're going to say about the dockerfile environment today:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1a7.tmp "border=" 0 "alt=" wpsb1a7.tmp "src=" http://s3.51cto.com/wyfs02/M01/83/CF/ Wkiom1d8ypnzthk0aabt0f9durm691.jpg "width=" 549 "height=" 407 "/>,
Dockerfile Simple:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1b8.tmp "border=" 0 "alt=" wpsb1b8.tmp "src=" http://s3.51cto.com/wyfs02/M02/83/CF/ Wkiom1d8ypytgrveaabll-3fors227.jpg "width=" 238 "height=" 484 "/>
1. Run parameter: We added the parameter run yum install–y vim* in the dockerfile created in the previous chapter:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1c8.tmp "border=" 0 "alt=" wpsb1c8.tmp "src=" http://s3.51cto.com/wyfs02/M01/83/CD/ Wkiol1d8yp3hxbyraaax5d1p1w4910.jpg "width=" 430 "height=" 325 "/>
2, try to build, you will find that the Dockerfile run parameter takes effect:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1d9.tmp "border=" 0 "alt=" wpsb1d9.tmp "src=" http://s3.51cto.com/wyfs02/M02/83/CD/ Wkiol1d8yp6qlaekaacepo0h_le679.jpg "width=" 390 "height=" 243 "/>
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1ea.tmp "border=" 0 "alt=" wpsb1ea.tmp "src=" http://s3.51cto.com/wyfs02/M01/83/CD/ Wkiol1d8yp_q1oxvaabbhcsjssk771.jpg "width=" 331 "height=" 161 "/>
3, so, the role of run is to help you run some of the pre-run commands, but it is best not to do in run like "Yum Update", "Apt-get Update" and other operations, this does not conform to dockerfile best practice.
4, CMD parameters: Introduction to run will have to introduce the next cmd, cmd command and run, the difference is that cmd in a dockerfile can only be used once, if there is more than one cmd in Dockerfile, the default is to run only the last one, for example, you can write a sentence in the last line "Enjoy Your Docker images", the CMD call is special, is automatically triggered by the completion of the container with your images, such as Docker run Imagesname:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1fa.tmp "border=" 0 "alt=" wpsb1fa.tmp "src=" http://s3.51cto.com/wyfs02/M00/83/CD/ Wkiol1d8yp-bygn7aaalvea-kzy268.jpg "width=" 348 "height=" "/>"
5, expoes parameter: This parameter is used to specify container need to expose to other container port, equivalent to build internal network, and the difference between-P is that the expoes is provided internally port method (container, such as NGX access to MySQL),- The P parameter is the mapping port equivalent to NAT, such as:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb1fb.tmp "border=" 0 "alt=" wpsb1fb.tmp "src=" http://s3.51cto.com/wyfs02/M01/83/CD/ Wkiol1d8yqccezpfaabdwko29pa591.jpg "width=" 263 "height=" 169 "/>
6, the completion of construction:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb21b.tmp "border=" 0 "alt=" wpsb21b.tmp "src=" http://s3.51cto.com/wyfs02/M01/83/CF/ Wkiom1d8yqgzdxfeaaekankjyuo556.jpg "width=" 335 "height=" 484 "/>
7, then, we create two containers through this images, we understand the role of expose parameters, you can see there appears "Port 22":
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb23c.tmp "border=" 0 "alt=" wpsb23c.tmp "src=" http://s3.51cto.com/wyfs02/M02/83/CF/ Wkiom1d8yqkriub-aadct5wguj8343.jpg "width=" 591 "height=" 222 "/>
8, but is not visible in the port mapping table, prove that this is an internal mapping port:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb25c.tmp "border=" 0 "alt=" wpsb25c.tmp "src=" http://s3.51cto.com/wyfs02/M02/83/CE/ Wkiol1d8yqpwdix2aacwwxoe68u948.jpg "width=" 644 "height=" 288 "/>
9. Enter one of the containers and use Nmap to test whether the port of another container can be connected:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb28c.tmp "border=" 0 "alt=" wpsb28c.tmp "src=" http://s3.51cto.com/wyfs02/M02/83/CF/ Wkiom1d8yqxqx3tlaafk9g9fojk885.jpg "width=" 503 "height=" 484 "/>
10, entrypoint parameters : This can be seen expose role, sharp-eyed people may see I use entrypoint this parameter, entrypoint this parameter properties and cmd a bit like, The same is true when more than one parameter is present, and in this case, I use this parameter to run the SSH service as a background service:
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px; "title=" wpsb29c.tmp "border=" 0 "alt=" wpsb29c.tmp "src=" http://s3.51cto.com/wyfs02/M01/83/CF/ Wkiom1d8yqwizj-maabxgybwc_8710.jpg "width=" height= "168"/>
650) this.width=650; "Style=" background-image:none;padding-left:0px;padding-right:0px;float:none; Border-top-width:0px;border-bottom-width:0px;margin-left:auto;border-left-width:0px;margin-right:auto; padding-top:0px, "title=" logo "border=" 0 "alt=" logo "src=" http://s3.51cto.com/wyfs02/M02/83/CF/ Wkiom1d8yqfznqqqaaeab8so6zk508.png "width=" 530 "height=" 347 "/>
This article from "Vmcloud" blog, declined reprint!
"Vmcloud Cloud Platform" embracing Docker (vi) about Dockerfile (2)