Alibabacloud.com offers a wide variety of articles about docker dockerfile tutorial, easily find your docker dockerfile tutorial information here online.
Docker there's a dockerfile, why should we use him?To put it simply: we used to Docker run to create a Docker container that sometimes comes with a lot of parameters.Like what:
The code is as follows
Copy Code
Docker run-d-P 22-p 8080:8080 Ruifen
Original source: http://blog.csdn.net/anxpp/article/details/52495309
Dockerfile is a text-formatted configuration file that we can use to quickly create a custom image using the Dockerfile file.
Many of the instructions supported by Dockerfile are the main things to be covered in this article, followed by a basic example.
In general,
List of files prepared on the host:
Dockerfile
#启动ssh和apache服务的角本
run.sh1 2 3 1 2 3
The above files are placed in the/root/apache_centos directory
Mkdir-p/root/apache_centos
Cd/root/apache_centos1 2 1 2
Base Image: An image of an open SSH service based on a mirrored CentOS
[Root@localhost apache_centos]# Docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SI
dockerfile File
Dockerfile uses a DSL -based directive to build a Docker image, and then uses the Docker build command to build a new image based on the Dockerfile directive.
About the DSL language, Bo Master carefully consulted, interested can refer to Guo Xiaogang teacher
General references and recommendations
The Docker build command uses Dockerfile or context to build the image, and the build context is a file of the specified local path or URL. The local path is the directory of the local file system, and the URL is the local git repository. The build is run by the Docker daemon, not the CLI. The first thing to do in the build
Dockerfile Create a local mirror
This blog post will describe how to create a local mirror in Docker. The content includes writing dockerfile files, creating mirrors from the written dockerfile, mirroring the created process, and running the mirrors created.
Dockerfile is u
Dockerfile features and their workflowDocker can create an image by automatically reading the Dockerfile file, Dockerfile is a text document type, where all the actions commands that the user can make at the command line can be defined here, combining these commands and generating a directly available image. With Docker
Dockerfike quickly create a custom Docker mirrorA, Table of contents1.docker Typical structure2. Instruction Introduction3. Create Docker Mirrors
Second, the structureThe Dockerfile is divided into four parts: the underlying mirror letter, the maintainer information, the mirroring operation instructions, and the execut
After the Docker 17.05 release, a new Dockerfile multi-stage build was added. The so-called multi-stage build, in effect, allows multiple from directives to appear in a dockerfile. What is the point of doing this?
Why does the old version of Docker not support multiple from directives
Prior to the 17.05 release of
Docker Learning Note II, based on Dockerfile to build Java Tomcat Runtime environmentObjectiveIn the first text, we completely manual, a command of a command input, implementation of a Java Tomcat runtime environment, although the initial results, but very tiring. If you rely on scripting to build a Tomcat container instance, a command can be done, why not. Fortunately,
Docker Dockerfile Detailed Category: DevOps 2014-05-15 11:0921652 People readComments (0)CollectionReportDockerdirectory (?) [+] How to use Dockerfile is used to create a custom image that contains user-specified software dependencies, and so on. Under current directory contains Dockerfile, use command build to create
actually equivalent to creating a template image, which can then be used to create a specific sub-image based on the template image, and some common operations that need to be performed during the sub-image build process can be specified in the Dockerfile file corresponding to the template image with the onbuild directive. This reduces the duplication of dockerfile files.Let's look at a simple example.1, f
Build Docker Image
Simple recording of how to build Docker image
Build Docker image Docker build Usage dockerfile related instruction RUN CMD entrypoint SHELL CMD entrypoint building ACTIVEMQ Image Reference
The Docker build Usag
containers to be shared.Ii. creating a mount point from DockerfileThe mount points that are created above with the-V identity of the Docker Run command are valid only for the container that you create.The dockerfile VOLUME instruction allows you to create a mount point in the mirror so that only the containers created through the image have mount points.Another difference is that the mount point created by
Using Dockerfile to create CentOS Docker mirrors with Apache services
List of files prepared on the host:
Dockerfile
#启动ssh和apache服务的角本
run.sh
The above files are placed in the/root/apache_centos directory
Mkdir-p/root/apache_centos
Cd/root/apache_centos
Base mirroring: Mirroring of open SSH services based on mirrored CentOS
[R
syntax and commands, and you can refer to Docker's official documentation.
2. With the Dockerfile file, you can create image files based on Dockerfile, and in the directory where Dockerfile is located, run the following command
sudo docker build-t centos6-ssh.
When the command succeeds, an image named Centos6-ssh i
The command used in Dockerfile has a base image specified from the from from, and in general a usable dockerfile must be from for the first instruction.
As for the image, it can be any image image that is reasonably present.
The from must be the first non-annotated instruction Dockerfile.
The from can appear multiple times in a
parameters: Read our introduction volume The students should know volume This parameter is used to do what, here do not introduce, if not specified in the Dockerfile, can be specified by-V, of course, the two are different, For details, refer to the fifth chapter of the Docker article.2, workdir parameter: Use this parameter can specify "Run directory", for example you need a command to run under/bin/bash,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.