In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The original article is welcome to reprint. Reprint please indicate: reproduced from IT Story Association, thank you!
> > original link address: "docker practical articles" docker-docker image of python is created using dockerfile (33)
You can learn from the previous docker commit that the customization of the image is actually the configuration and file added at each layer. If you write the modified configuration and file of each layer into the script, and use this script to build a custom image, the problem of unrepeatability, the transparency of image construction, and the volume problem will be solved. The script is Dockerfile.
Dockerfile
What is dockerfile?
A text file that contains instructions, each of which builds a layer, so the content of each instruction is to describe how the layer should be built.
Learn about FROM
FROM specifies the base image, which must be specified. FROM specifies the base image, so From is a necessary instruction in a Dockerfile, and it must be the first instruction. There are many high-quality docker images on dockerhub, and there is a basic image that can be used directly: nginx,tomcat,java,python,php,mongodb. Search for a base image that best fits your use.
Learn about RUN
RUN execute commands are used to execute command-line commands. Because of the powerful power of the command line, the RUN instruction is one of the most commonly used instructions when customizing images.
Shell format: RUN, just like commands entered directly on the command line: exec format: RUN ["executable file", "parameter 1", "parameter 2"], which is more like the format in function calls
It is not recommended to write the following Dockerfile
> as mentioned earlier, Dockerfile creates a layer for each instruction. The following way of writing is to create a 7-layer image. This is completely meaningless. A lot of things that are not needed to run are installed in this image. The compilation environment updates the software package and produces very bloated layers of images. This not only increases the time to build and deploy, but is also easy to make mistakes. It is also an easy mistake for beginners to make docker. I've done it before. There is a limit to the number of layers of the mirror, with a maximum of 127 layers. The image is stored in multiple layers, and the previous layer will not be modified when one layer is added.
The right way. Be sure to make sure that each floor is needed, and anything irrelevant must be cleaned up. This is also an easy mistake to make an image, and the previously installed files have not been cleaned up.
Writing Dockerfile in actual combat
Create a directory to store Dockerfile
Mkdir newNginxcd newNginx
Write Dockerfile
From nginxRUN echo 'welcome to idig8.com study docker' > / usr/share/nginx/html/index.html
Build Dockerfile
Docker build-t nginx:v2 .docker images
Push docker hub push
Logging in to docker hub
# configure dns 8.8.8.8 vi / etc/resolv.confdocker login first
Set the warehouse address and log in to hub.docker.com
Change the name
Docker tag nginx:v2 zhugeaming/nginx:v2
Complete push
Docker push zhugeaming/nginx:v2
View the result
PS: in fact, when you are developing, when you are multitasking, you only need a mirror environment of python3 and mitmproxy. You have already done it. Then you can use docker push zhugeaming/python3-appium directly. In fact, if you want to learn other content about docker, you can see other articles I wrote earlier.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.