[Docker] Docker Images – Dockerfile Concepts and Creation Methods

[See reference site] – – [Docker]Docker image – Docker Image – Docker1. How to generate image by using Docker FileTo generate applications when you developing applications that are developed applications.① A container is generated in an image (ex.Ubuntu, and the agent OS).② Installation of the application and verify that the source code and works well.③ Image and commitment to commitment

This method requires installation in everything to configure the environment, and copy the source code to clone the source code to clone the source code to clone the source code.Of course, it is also possible to commit the image as a direct container, so that you can guarantee the image operation.

This method requires installation in everything to configure the environment, and copy the source code to clone the source code to clone the source code to clone the source code.Of course, it is also possible to commit the image as a direct container, so that you can guarantee the image operation.

Ubuntu からENTRYPOINT [“top”, “-b”]CMD [-c”]

3. Before building an image in Dockerfile, I checked the Dockerfile command, so I will create an image in Dockerfile.Below is the Dockerfile that creates the node JS image.

## ## nodejs-server## build:# docker build –force-rm -t nodejs-server .# run:# docker run –rm -it –name nodejs-server nodejs-server#FROMノード: 16LABEL maintainer=”ですSeunghwan Seo <[email protected] >”LABEL description=”ですスンファンのNode.js server”# アプリディレクトリを作成しますWORKDIR /app# Install app dependencies#If both packages are used to ensure that both packages are available.js/oru-lock.js for use the # for use of the no longer available (npm@5+) for use #1 . . .EXPOSE 8080CMD [ “node”, “server.js” ]Run theBefore you build a locker file, you can easily analyze the above Docker file, you will obtain image of the FROM-> node JS16 version.Move the WORKR ->To run the location to/app/directory.Copy all files from the current directory of the COPY->host OS, copy all files to copy all files to the current directory.js on the current directory.js.js.js.Because I specified the RUN->npm installation, copy the WORKETER, and paste the current position to the COMPIR command.COPY->COPY is a configuration in the COMPIY, and the destination is the CDPY, and all the Docker file on the image.In other words, the COMPIY… is to run after this layer.EXPOSE ->80 ports using an EX POSE ->80 ports.Run the ‘node Server.js’ command in the CRM-> shell.Create image from this to the Docker file.Enter the following command.$ docker build –force-rm -t nodejs-server:1.0.0 .- Set the name of the image that is generated.When you run the above command, the name of the name of the name of the name of the nodejs-server:1.0.0.- If you do not use the option, you recommend that you can use the -t option to use the -t option.At the last of the dock command, enter the path that the Docker file is saved.Generally, use the docking file to be saved locally, but you can also read the contents of the locker file from outside URL.In this example, you saved the Docker file, and then delete the temporary container that is generated in the middle of the source-rm option ->.When you start building, the above content is output and generates the image of the name of the name of the name of the name of the name of the name of the name of the name of the name.When the container is running, the node JS server, the node JS server, the node JS server will run the container.jsコマンド command is executed.Then, enter the following command to perform the container in the generated image.$ docker run – d – P — name my_nodejs_server nodejs-server: 1.0.0$ docker run – d – P — name my_nodejs_server nodejs-server: 1.0.0$ docker run – d – P — name my_nodejs_server nodejs-server: 1.0.0If you connect to the container, you can verify the build context.The build context is used when adding files to the image that are built in the docking file.To add files to the image in the locker file, COMPIY, COPY, COPY.These commands add files to the image of the build context.In the above example, you can read the backup path to/app.js on the build context.js on the build context.js.js.Information about context, the content of the content that was output when build image.If you connect to the container, you can verify the build context.The build context is used when adding files to the image that are built in the docking file.To add files to the image in the locker file, COMPIY, COPY, COPY.These commands add files to the image of the build context.In the above example, you can read the backup path to/app.js on the build context.js on the build context.js.js.Information about context, the content of the content that was output when build image.test.html。html*/*。html. テスト。HTM?The path that exclude from the context is based on the path that the DSocker file is based on the path that the Docker file.For example, the path that you set in the default directory, the *.h817/sh817/sh817/s.tml is/h817/shtml is the .t.Similarly,*/*.html is not the file that falls under/home/*/*/*/*/*/*/*/*/*.html.In other words, the directory level that are divided into*/s, you can see any directory level and what directory is going to come.Test.html? The test.htm to remove files in the location of the location.htm.In other words, the .docker, test.html, test.htmb…htmb.If you want to configure only, use only special files, use the “!” if you want to configure only special files.”!” means that you do not exclude specific files.The following example removes all files that are the extension of the extension of the file that starts with the test.*.html!Test*.html(3) The generated and commit building commands used to create a container after running a container, and the completed image after running container.However, the process that creates imageIt is not generated in one container.You can guess if you build images, you can guess the following: the following: The following is displayed when you build images.Each step applies to the command that was recorded in the docking command.Each time the command is generated by the FROM, the WOR, and WORKR, and the WORKR, and commit this as image.In other words, the new container is generated by the previous step, the image generated by the previous step, and the command is generated as a new container is generated and stored in the docking layer.Therefore, the image build is to exist only for the number of layers of the Docker file, and delete only the same number of container is generated.In the output result, the Rovging interface… is temporarily generated by deleting the image layer.(4)After finishing image build, use the cache to use the cache, use the cache that you used in previous image build.Save the following contents as file, and build the image.The following Docker file removed from the image that you built from the image.FROM node: 16LABEL Maintenance=” is the Sun-woofer [email protected] >” in the fan.jserver.jserver.jserver.jserver.jserver.jserver.jserver.j.Save the name of the docking file 2 as a docking file 2.You can specify the name of the locker file in the docker Builder command.Then, enter the docker Builder command to docker build-focker file 2-t cache:0./ .$ docker build -f Dockerfile2 – tcache: 0.0./$ docker build -f Dockerfile2 – tcache: 0.0./The output contents of the output of the output of the operation called Update Cache, and it was created immediately.If there is the same content in the previous build locker file, the build command is not built to create image without a new command line.This is built to build multiple images that you need to build multiple images and other errors during build. * If the error occurs during the image build?If an error occurs during image build, the build command is stopped and remains deleted for image layer generation.Also, the image is not complete, so that the image is not the name of the image specified in the またnoneで none”—No.To delete these images, dockermix [imageid]You should delete the image in the command.However, there are no cache functionality is not required.As shown above, this applies to the image code such as GigabitHub, such as GigabitHub is shown in the repository.If you build the image to the locker file, the image layer is used as cache, the actual Gits pertaining to the RUN is always used as cache.If this case, add a – no-n-cache option to add-no-cache option.- If you use- no-cache option, you can rebuild the Docker file to rebuild the Docker.$ docker build –no-cache -f Dockerfile2 – tcache: 0.0/Alternatively, you can also specify the image that you want to use as cache.- You can use the image to expand the image to use the existing locker file, you can use as a build cache.For example, you can use the enginex:lips the enginex:lips the directory that you want to build a copy of the file.$ docker build — cache- from nginx my-extend_nginx:0.0.0 .$ docker build — cache- from nginx my-extend_nginx:0.0.0 .