In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The knowledge points of this article include: the installation and download of docker image, the layering of docker image and the cache feature of docker image. I believe you have some understanding of docker image after reading the complete article.
Download image (composition of dockerfile)
Docker pull hello-world
The composition of Dockerfile
1. "FROM:scratch scratch, scratch (build from scratch)
2 "COPY: hello /
3 "CMD: [" / hello "]
Base Mirror
(basic image)
> * personal understanding: > user Space: rootfs > Kernel Space: bootfs > kernel Kernel > overall, there are seven parts: > docker client,docker daemon,driver,libcontainer, > docker container,graph,docker registry > > docker is a Cmax S architecture. The user can enter various instructions on the client, and the client is responsible for accepting the request and returning the corresponding response to the customer. > DockerClient > DockerClient is responsible for receiving and delivering request instructions. > DockerDaemon > background running (does not occupy programs and ports) > DockerDaemon has two main functions: (is a daemon) > 1. Responsible for accepting client's request 2. The architecture for managing docker container > dockerdaemon can be divided into two parts: dockerserver and engine > DockerServer as the server side, the main function is to cooperate with the client side to accept the request instructions. As shown in the figure, DockerServer is mainly divided into three parts: Http.server,routermux.server,Handler > DockerServer runtime creates a mux.Router router from a package called mux, and then adds relevant routing entries to the router for routing information. Each routing item consists of three parts: HTTP request method (get,post,put,delete) + URL+Handler. > every time DockerServer receives a request, it generates a goroutine, then parses it, matches the corresponding routing items, and finally finds a matching Handler for processing. After processing the request, Handler returns a response to DockerClient > 2.Engine > Engine is the running engine in docker, which stores a large amount of container information and manages most of the execution of job. > > job is the smallest execution unit in docker, similar to processes in unix, with corresponding names, parameters, environment variables, standard input and output, return status, and so on. Each time docker performs a corresponding operation, it generates a corresponding Job, such as creating a container, downloading a file, and so on, which is done by job. > DockerDriver > DockerDriver is the internal driver module of docker, responsible for the construction of related networks and file systems inside the container > > libcontainer > libcontainer mainly encapsulates some features of the linux kernel, such as namespace, cgroups, capabilities, etc. > > Graph > DockerRegistry (private repository) > Docker Container: specific containers for running applications It is the delivery entity of container service * Summary: document (online) Docker core concepts * * there are three core concepts of container technology: container (container), image (image) and registry (warehouse). Container: a specific process that runs the application, which contains the various dependencies of the application. Image: create a template for containers, and create different containers for use according to different configurations of images. The relationship between mirror and container can be understood as the relationship between class and instance object in object-oriented. Repository: only one type of container can be created for an image. If there are more images, you need to store them in the image repository, which has a local image repository and a public image warehouse. Usually use the images from the local warehouse. If not, go to the Registry hub public image warehouse to download them. The Docker architecture Docker framework is mainly composed of five modules: Docker Client, Docker Daemon, Docker Registry, Driver and Docker Container, as well as two auxiliary modules, Graph and Libcontainer, as shown in the following figure: Docker architecture Docker Client: users communicate with Docker Daemon through Docker Client, and use the command line to send requests such as creating images and running containers. Docker Daemon:Docker Daemon is a background-resident system process in Docker architecture that accepts and processes requests sent by Docker Client. The daemon starts a Server,Server in the background to accept requests sent by Docker Client, and then finds the appropriate Handler to execute the request through routing and distribution scheduling. Docker Registry: the repository where container images are stored. Driver: Driver is the driver module in the Docker architecture. Through Driver driver, Docker can customize the execution environment of Docker container. It includes a graphdriver driver for managing container images, a networkdriver driver for configuring the network environment in the container, and execdriver is used to create and maintain containers. Docker Container: the specific container that runs the application and is the delivery entity of the container service. The general operation process is as follows: after the user sends the request to the Server in the Docker Daemon,Docker Daemon through the command line on the Docker Client side, Engine will create a work task job and perform different tasks by calling each driver of the Driver module. For example, if you need an image, call graphdriver to download the image from the image repository. When creating a container, you also need to call the other two drivers to configure the network and create and maintain the container. Finally, the running container is generated or the image is uploaded to the image repository. When a container application wants to use a container to run its own application, it first needs to be clear about the environment on which the application depends. If there is a local ready-made image that can be directly used to run the container application, you can download it through registry hub via docker pull, or create the required image yourself. You can use dockerfile to create an image. First, edit a dockerfile file, where FROM indicates which image the image is based on to establish the MAINTAINER. It indicates who maintains the operation that the RUN tells the image to perform, such as updating or installing a software, and creates a new image layer. EXPOSE represents the exposed port. ENV indicates the configuration environment variable CMD sets the command and its parameters that are executed by default after the container starts. This command will be run when the container starts and docker run does not specify other commands. If docker run specifies other commands, the default commands specified by CMD will be ignored. CMD has three formats: Exec format: CMD ["executable", "param1", "param2"] CMD ["param1", "param2"] this is generally used to provide the default parameter Shell format for ENTRYPOINT: the command that the CMD command param1 param2ENTRYPOINT configuration container runs at startup. Unlike CMD, ENTRYPOINT's instructions must be run, even if other commands are specified when running docker run. ENTRYPOINT has two formats: Exec format: ENTRYPOINT ["executable", "param1", "param2"] Shell format: ENTRYPOINT command param1 param2 generally gives priority to ENTRYPOINT instructions in Exec format. CMD provides additional default parameters for ENTRYPOINT and replaces them with the docker run command line. Commonly used commands Docker build to create an image Docker run uses a series of operations about the image from the image running container Docker image Docker pull downloads the image from the image repository to the local warehouse Docker push uploads the image to the image repository Docker container performs a series of operations about the container Docker stats monitors the resource usage of the node container in real time
Layering of mirrors
The writing format of 1 "dockerfile is: Dockerfile
2 "FROM: there are two ways to build an image, one is scratch (build from scratch), and the other can be built based on an image.
3 "the operation run by the mirror, (what the user expects)
Vim Dockerfile
Run it.
Docker build-t centos7-vim-net-tools:12-11.
. Dot means to automatically find Dockerfile files in the current directory
Note: the viewing order of the images, from top to bottom
Hierarchical summary of Dockerfile images:
The image is the cornerstone of the container, and the container is the instance after the image is run. When the image runs as a container, it only has read-only access to all the data of the image. If you need to modify or delete the image source file, it is really carried out in the container layer (writable layer), using the cow (copy on write) write-time replication mechanism.
Caching characteristics of Docker images:
It is best to have only one Dockerfile file in a directory
Create a new dockerfile file
Run it.
Docker build-t new-centos.
If you have the same image on the same layer, you don't have to download it anymore, you can use the cache directly.
Even if it is the same image, it will be downloaded on different layers.
View the history of the mirror
Docker history centos7-vim-net-tools:12-11
Docker history new-centos:latest
Mkdir test1 is creating a dockerfile
Even if the mirror does the same thing, it must be at the same layer to use the caching features of dockerfile.
If you do not want to use caching during mirroring, you can add the-- no-cache option.
After reading the above, do you have any further understanding of docker images? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
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.