Introduction to Docker

Docker introduction


Docker related terms to understand:
1. Mirror: It is a program code that can be run (files packaged with related packaging tools). Such as: Ubuntu mirror. This Ubuntu system runs when you run the ubutu image on Docker. Of course, your image can also be based on host system calls.
2. Container: It is a code space that is decompressed from the image and can be run (it is a file in Docker). In short, it is an application, and it is a process when it is running. For example, when I run an image, I actually create a process on the host and generate a container file (the file name is the container name). This container (program) can be run, stopped, and deleted in Docker.
3. Basic image: It is the most basic image file. You may extend some functions based on it (such as: Ubuntu image, you can install more applications), and then make a new image, and This image can also be used as a base image.
4. A container can also be understood as a system (such as Ubuntu) or an application (such as: Tomcat) that can run other applications

and the difference between a virtual machine:
1. When the image is an image running on the host system, Running with Docker containers will perform much better than virtual machines.
2. When the image is also based on an Ubuntu system ring, it is not much different from the virtual machine. Of course, the performance should be better than that of the virtual machine. After all, it is an optimized Ubuntu image.
3. Docker shares the kernel (with the host), but the operating system in the image is not shared, that is, the system calls of the kernel use the system API in the host, but the operating system is owned by each container itself.
4. The relationship between the kernel and the operating system. The operating system is the outer layer of the kernel. The operating system is a library or interface (such as shell, software manager, etc.) that adds some outer applications to the kernel to facilitate user development. The operating system is A name for a collection of applications that are convenient for users to use the computer and use kernel resources.
5. The application of the virtual machine runs on the operating system on the guest machine, but the operating system is the kernel running on the guest machine, the kernel runs on a virtual hardware, and the virtual hardware runs on the host system. The host's system runs in the host's kernel, so there are two to three more software layers than docker, and the running speed will be much slower.
6. But the running environment of the virtual machine is completely independent, while docker is only the container independent kernel is shared, and there will be resource sharing (not completely independent)


benefits:
1. There are problems: when you develop based on the host When you want to apply the application to the production environment (test development environment), you need to rebuild a running environment in the production environment that is the same as the development environment (install various software (such as tomcat, JVM, JDK) and environment variables setting).
2. Solution: Based on the Ubuntu image, add various functions (install various software (such as: tomcat, JVM, JDK) and the setting of environment variables) to generate a new image, to put it bluntly, install the various functions on Ubuntu. After the software is installed, the Ubuntu system is repackaged into a new Ubuntu image.
3. The new image can be run directly on Docker. After running this image, you can get an environment with everything installed, without you having to install it one by one. Using this method to build the environment and deploy the service is very fast, and the environment is the same.


Docker composition:
1.Docker Hub: Docker central service, which is a shared center. After you register an account, you can send (publish) your own images to here for others to download and use.
2. Docker daemon: Docker uses a client-server (C/S) architecture pattern. The Docker daemon handles the heavy lifting such as building, running, and publishing your Docker containers.
3. Docker client: The Docker client communicates with the Docker daemon. The Docker client and the daemon can run on the same system, but you can also use the Docker client to connect to a remote Docker daemon. Docker client and daemon communicate via socket or RESTful API.
4. After installing Docker, the Docker daemon and the Docker client will be installed on the local machine (host machine). The two can only be separated into two parts by function, which is convenient for remote management of the Docker daemon.


Docker Hub
1. Docker Hub is docker Central warehouse. Docker Hub stores public Docker images and provides services to help you build and manage your Docker environment.
2. After you register an account, it will give you a warehouse space, and you can put your Docker image on it and be downloaded and used by others.


Image loading:
1. When you specify an image, docker will check whether the image has been loaded on your docker host once. If it is not found, docker will download the public image from the image repository Docker Hub.


To create our own image:
1. We can update the image from the container that has been created and submit this image. (Take the Ubuntu image as an example)
(1) Run the container, add the functions you want to add (such as installing Tomcat) in the container (that is, the Ubuntu system)
(2) After installing the application, exit the container
(3) Use Docker's command to generate an image (docker commit command) to generate a new image file

2. You can use the Dockerfile command to create an image.
(1) Using the docker commit command to extend the image is very simple, but it is a bit cumbersome: it is not easy to share its development process within a team. (Just can't see where you started based on that image and what you added to it), the Dockerfile instruction is used to solve this problem.
(2) The method is to write a Dockerfile file, which writes the relevant installation process commands (in a certain format),
(3) Use the docker build command and the Dockerfile file to generate a new image.
(4) When running the container from the new image (that is, loading the image), the image generation process information will be output in the way of generating the image, so that you can know how the image is generated.
(5) Dockerfile describes in detail how the image is built and the commands to be executed at runtime.


An example description:
1. You use Docker, download an ubuntu image from the official repository, and use it as the most basic image. Then run a container on it, download Nginx in this container, and then generate a new image based on this container.
2. In the future, the containers generated by this image will be based on ubuntu+nginx.
3. But your working environment may require you to use Apache to work, and you also want to have a ubuntu+apache-based image, so you can use the most basic ubuntu image to run a container, download and install Apache in it, and then use this container As a basis, save an image of ubuntu+apache, and all containers running on the basis of this image will have an apache environment.


Docker uses:
1. Consistent microenvironment.
2. The deployment is fast, just run the image.


Reference original text (docker introduction, application): http://wiki.jikexueyuan.com/project/docker/userguide/usingdocker.html
Reference original text (docker introduction): http://www.open-open.com/lib/view /open1423703640748.html
Reference text (minimum Docker image hello-world analysis): http://blog.csdn.net/hazir/article/details/45111161
Reference text (Docker and virtual machine performance comparison): http://sanwen8. cn/p/182zEbE.html
Reference text (in-depth analysis of Docker mirroring principle): http://www.csdn.net/article/2015-08-21/2825511
Reference text (Docker nature and version selection): http://www.csdn.net/article/2015-08-21/2825511 blog.csdn.net/abcdocker/article/details/53158212
Reference text (Introduction to Docker): https://opskumu.gitbooks.io/docker/content/chapter5.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326988898&siteId=291194637