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

What can Docker do?

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

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what can Docker do". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is Docker?

Open Mr. Translator and enter Docker. The result shows that the Dockers are right! Dockers carry containers, so the Docker we are going to talk about today is also about containers. This container is an application image file statically, and dynamically, it is a container. Are you fooled? All right, explain in the picture above.

Docker is a process in a narrow sense and a virtual container in a broad sense. In fact, a more professional name is application container (Application Container). There is no difference between a Docker process and an ordinary process, it is an ordinary application process. It's just used to manipulate the image file. So the application image file built by the Docker process + is equal to the Docker container. All the Docker mentioned in this article refers to the Docker container.

Before continuing below, let's first clarify a few important basic concepts of docker: images, containers, and repositories.

Mirrored Docker images is similar to snapshots in VM virtual machines, but much lighter than snapshots. The snapshot doesn't understand? Then you can think of images directly as a folder. We can confirm the unique target image by ID or the easily recognizable name + tag. ImagesID is a 64-bit character, but usually we use the first 12 bits to make a difference.

Container Docker containers, you can create a container from an image, which is like creating a virtual machine from a snapshot, but it is lighter, starts faster and starts in seconds. The application runs in a container. For example, you first download a Ubuntu image, and then install mysql and Django applications and their dependencies to complete the modification of its Ubutun image. Share this image with you, and you will generate a container through this image. After the container starts, the Django service will run.

Warehouse Docker registeries,docker warehouse is the same as the container warehouse, but docker is used to store images. Repositories can be divided into public and private. Docker hub provides a large number of images, which can be pulled down and run, or you can upload your own images to docker hub. At the same time, you can also build your own private warehouse for team project management.

Combined with the basic concepts introduced earlier, we can roughly string together several concepts of docker and how they work between them, that is, the lifecycle of Docker. Look at the picture below, mainly in three steps.

Let's take a look at the difference between the two, because the Hypervisor of VM needs to virtualize the hardware and install its own operating system, in which the virtual machine operating system takes up a large amount of memory, and an operating system has several gigabytes, so naturally there is a lot of overhead in startup speed, resource utilization and performance. If you are locally or on a personal computer, the impact is not so great. But in the cloud is a very big waste of resources.

Most of the time, when we do things, we will not consider problems that have nothing to do with the thing itself. For example, aircraft builders will not consider whether the plane should dive or not. For many of our current mobile Internet applications, we rarely involve the part of the operating system. In fact, we are mainly concerned about the application itself, and the upper layer of the VM virtual machine is the runtime library and applications. The space of the whole virtual machine is very huge. However, after the emergence of containerization technology Docker technology, the operating system layer is omitted. Multiple containers are isolated from each other and share the host operating system and runtime library.

Therefore, the Docker application container has the following advantages over VM:

The startup speed is fast, and the essence of container startup is to start a process at a time, so they all start in seconds, while VM usually takes longer.

Resource utilization is high, an ordinary PC can run hundreds of containers, you run ten VM to try.

The performance overhead is small, and VM usually requires additional CPU and memory to complete the functions of OS, which takes up additional resources.

So many mobile Internet applications or cloud computing back-end nodes can use docker to replace physical machines or virtual machines. For example, many of Tencent Map's backend services are basically migrated to docker deployment.

What kind of architecture is Docker? What kind of technology is used at the bottom?

Having said so much before, I still look at the flowers in vagueness. The following is a detailed description of the technical architecture, what technology is used at the bottom to achieve so many of the above advantages?

Docker Technical Architecture Diagram:

Docker installation

Installing docker through a script is very simple.

1. Get the latest docker installation package

Nicktang@nicktang-virtual-machine:~$ wget-qO- https://get.docker.com/ | sh

The version number can be seen, indicating the successful installation of docker. Easy! All that's missing is a mirror image. It's up to you to make it yourself or pull it from the public warehouse.

Root@nicktang-virtual-machine:/data # sudo service docker stop # shut down the daemon

Docker usage

With regard to the use of Docker, we mainly talk about how to use docker from several aspects, why not change it, because in my opinion, once there is a problem with the docker container, there is no need to repair it. Just stop and delete the container and start it again. So we only need to master a few basic commands, as follows.

[check] check the existing local image Docker images

When you use docker images to view it, the local centos image is added.

The first field is the container ID that has been launched, and the second field is the image from which the container is generated. But the above command only temporarily starts the container. The status in the image above is exited (0), indicating that the container is in an exit state. If you want the container to run in the background, so we need to start the guardian container, just add a-d parameter to the startup command, that is, docker run-d centos.

[check] View the details of the image / container docker inspect image ID (image name) / container ID (container name) docker inspect centos

This command returns a json string of image or container details. It includes a lot of information such as ID,ip, version, the main program of the container, and so on. According to this information, we can carry out secondary development. Add a-f parameter to this command and we can specify to get the information we need, such as the IP address of the redis container, memory information, and CPU usage. Docker inspect-f'{{.NetworkSettings.IPAddress}}'[ID / Name]

Look at the container directory structure and find that it is exactly the same as the physical machine directory structure, which is why some people call docker containers also called virtual machines. Exit can exit the container terminal.

How to use Docker to achieve continuous integration, automatic delivery, automatic deployment?

I'm sorry to meet you these days if we don't talk about automation or persistence. So, we also need to learn about continuous integration, automatic delivery, and automatic deployment. But with so much said above, I didn't find that Docker has those three functions. Yes, Docker does not have this function, but you rely on Docker to complete the above three automation steps. Docker is the basis for the implementation of these processes, just like software development, software code is fundamental, development tools are auxiliary. Building a complete automated process also requires three kinds of help from github+jenkins+ registry.

The principles of continuous integration and automated deployment are shown in the following figure:

RD pushes the code to a code server such as git repository or svn, and the git server notifies jenkins through hook.

Jenkine clones the git code locally and compiles it through the dockerFile file.

Package to generate a new version of the image and push it to the repository, delete the current container, and re-run it through the new version of the image.

In the whole process, RD only needs to type three commands Git add *; Git commit-m "; Git push to complete continuous integration, automatic delivery, and automatic deployment. Later, through a case to demonstrate the magic of this process!

Docker can also be expanded automatically. Generally, there are two ways to expand capacity automatically. One is to expand the capacity of docker, and the other is to expand the number of docker nodes. The first is to modify the configuration file, and the second is to complete the expansion of the node by simply copying it.

This is the end of what Docker can do. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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