dockerfile Profile

There are two basic ways to mirror:

  1, based on container, using a docker commit to making this approach features small, do not do too much description here

  2, based on dockerfile, use docker build command

 

dockerfile Profile

  dockerfile merely used to construct a mirror source text file that contains all the commands to build mirrors, these instructions may be invoked from the command line. dockerfile format is command args, we use the command line # to comment. Under the command default command is not case sensitive, but usually we write uppercase. dockerfile when building docker image, dockerfile are executed sequentially, dockerfile first non-comment line should start with FROM, FROM defines the base image we use. dockerfile after every line of instructions will generate a new image layer. dockerfile all the instructions in the lower layer must be activated and the container after the container has been executed instructions supported.

 

dockerfile mirrored directory format

  Based dockerfile production docker image, there must be a dedicated directory, you must have Dockerfile files in your working directory, if we want to pack a lot of files in the production of mirror, then we must save the file in the working directory and its subdirectories, You can not be stored outside the working directory. If we use a new directory to save the file to be packaged in the mirror in the private directory, for convenience we may ADD (COPY) entire directory into docker image, if some files are not needed, we can work Directory under increased dockerignore file to define the unneeded files. So that when packaged, the file does not contain dockerignore automatically defined.

 

dockerfile instructions:

  FROM image: The first line must be placed in a non-comment line, specify the base to create a mirror image of

  COPY key = value key = value ...: decrease of the mirror metadata matedata

  COPY src dest or COPY [ "src", "src", ..., "dest"]: specify one or more directories to copy a directory in the file system image, typically src relative path, relative to the work directory, dest general is an absolute path (if it is a relative path, relative to the most recent WORKDIR defined above), attention to detail copy a file, only the src and dest (without the quotation marks), copy multiple files to the same directory needs use [], the src (requires quotes) EDITORIAL, dest (requires quotes) unloading Finally, separated by commas. If src is a directory, the directory itself and not copied, and copied files in a subdirectory of the directory

  ADD src dest or ADD [ "src", "src", ..., "dest"]: function with COPY, but ADD is supported src url manner, and if the local src to * .tar.gz, in a mirror dest will be extracted in the expansion, of course, if src is the url, even if the downloaded file is a * .tar.gz, it will not be expanded

  WORKDIR path: define the working directory, if the path copy or add the relative path, then it is its relatively above its nearest WORKDIR

  VOLUME amount: in this way the specified volume only hanging mount points within the image, the mount point on the host is automatically assigned docker daemon

  EXPOSE port / protocol port / protocol: Network access port exposed to the outside of the container, when docker run, the need to develop parameters -P exposed to white

  ENV key = value: setting environment variables, use $ {key}

  

  

  

Guess you like

Origin www.cnblogs.com/limaomao/p/11245870.html