Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker Mirror Management

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Each instruction in the hierarchical 1.Dockerfile of docker mirroring creates a new mirror layer 2. The mirror layer will be cached and reused. When the Dockerfile instruction is modified, the copied file changes, or the specified variable when building the image is different, the corresponding mirror layer cache will be invalidated. After the mirror cache of a certain layer expires, the mirror layer cache that follows it will fail 5. 5%. The mirror layer is immutable. If you add a file in one layer and delete it in the next layer, the image will still contain the file's Docker image. The Docker image is a standard format published by the application to support a Docker container's running Docker image creation method based on existing image creation based on local template creation based on Dockerfile creation. Based on the existing image creation, package the programs and running environment running in the container to generate a new image docker commit [option] Container ID/ name Warehouse name: [tag] option:-m description Information-an author Information-p stop the container running during generation 2. Create a new image based on the local template by importing the operating system template file to generate a new image using the wget command to import the local image Wqet http://download.openvz.org/template/ precreated/debian-7.0-x86-minimal.tar.gz. You can view the local image information docker images | grep new3. Creating Dockerfile based on FDockerfile is a file composed of a set of instructions Dockerfile structure four parts basic mirror information maintainer information mirror operation instruction container starts to use Dockerfile to create an image and run the Dockerfile operation instruction in the container meaning FROM image specifies the image on which the new image is based. The first instruction must be a FROM instruction, and each image creation requires a FROM instruction. The MAINTAINER name indicates the maintainer information of the new image. The RUN command executes the command on the image on which it is based and submits it to the new image. The CMD ["Program to run", "Parameter 1", "Parameter 2"] directs the command or script to run when starting the container. Dockerfile can only have one CMD command. If more than one is specified, the last one can only be executed. Specify the port ENV environment variable value to be opened when the new image is loaded into Docker. Set the value of an environment variable. The following RUN will use the ADD source file / directory target file / directory to copy the source file to the destination file. The source file should be located in the same directory as Dockerfile. Or an URLCOPY source file / directory destination file / directory copies the files / directories on the local host to the destination location The source file / directory should be in the same directory as Dockerfile VOLUME ["directory"] create a mount point in the container USER username / UID specify the WORKDIR path of the user when the container is run, specify the working directory ONBUILD command for the subsequent RUN, CMD, ENTRYPOINT, specify the generated image as a basic image, HEALTHCHECK health check example demonstration: 1. Create based on the existing image container # create container docker create- it jasonlix/ docker- cobbler / bin/ bashdocker commit-m "new"-a "daoke" c83aee844ae0 daoke:testdocker images | grep daoke2. Create wget http://dlownload.openvz.org/template/precreated/debian-7.0-x86-minimal.tar.gzcat debian-7.0-x86-minimal.tar.gz based on local template | docker import-daoke:newdocker images | grep new3. Private warehouse establishment docker pull registryvim / etc/dockerdaemon.json# add the following, modify the address "insecure-registries": ["IP address: 5000"] Systemctl restart docker.servicedocker create-it registry / bin/bashdocker ps-adocker start library ID# host's / data/registry automatically creates / tmp/registrydocker run-d-p 5000-v / data/registry:/tmp/registry registry# host's / data/registry automatically creates / tmp/registrydocker run-d-P 5000-v / data/registry:/tmp/registry registry# in the mount container and changes the mark to 192.168. one hundred and ninety five。 5000/nginxdocker tag nginx:latest IP address: 5000/nginx# upload docker push IP address: 5000/nginx# obtains private warehouse list curlI-XGET http://IP address: 5000/v2/_catalog# shows that the upload succeeded {"repositories": ["nginx"]} # Test Private Warehouse download docker pul1 IP address: 5000/nginx4. Port mapping docker run-d-P httpd:centosdocker run-d-p 49280 httpd:centosdocker ps 80 httpd:centosdocker ps-a 5. Container Interconnection # create and run the container named web1 Automatic mapping of port numbers docker run-itd-P-- name web1 centos / bin/bash # create and run the container name web2docker run-itd-P-- name web2-- link webl:web1 centos / bin/bash into the web2 container ping web16.Dockerfile file mkdir apachecd apachevim Dockerfile# based on the basic image FROM centos# maintenance image user information MAINTAINER The porject # mirror operation instructions install apache software RUN yum-y updateRUN yum-y install httpd# open port 80 EXPOSE 80 # copy the homepage file ADD index.html / var/www/html/index.html# of the website and copy the execution script to the ADD run.sh / run.shRUN chmod 755 / run.sh# startup container in the image. Execute the script CMD ["/ run.sh"] vim run.shrun.shrunxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (index.html#) docker build-t httpd:centos. # New mirror Like running container docker run-d-p 1216 httpd:centos# for testing and serving web page http://192.168.142.131:1216/

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report