In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to understand the introduction to Docker from 0. I hope you will get something after reading this article. Let's discuss it together.
Order
Docker has been widely concerned by major companies since open source, perhaps now the operation and maintenance system of Internet companies is not carried on Docker (or Pouch, etc.) are ashamed to say their own Internet companies.
This article will briefly introduce the basic concepts of Docker, entry-level usage, and some scenarios where using Docker can greatly improve efficiency.
Principle
The simplest and erroneous perception of Docker is that Docker is a very good virtual machine.
As mentioned above, this is a certain wrong statement. Docker is much more advanced than the traditional virtual machine technology, which is shown in that Docker does not virtualize a set of hardware on the host and then create an operating system, but allows the processes in the Docker container to run directly on the host (Docker isolates files, networks, etc.). In this way, Docker will be "lighter, run faster, and more can be created under the same host".
There are three core concepts in Docker: Image, Container, and Repository.
Image: programmers who tend to get "good guy cards" must be familiar with the concept of mirroring. But compared with the iso image of windows, the image in Docker is hierarchical and reusable, rather than a simple stack of files (similar to the difference between the source code of a compressed package and a git repository).
Container: the container cannot exist without the support of an image, which is a carrier of the image runtime (similar to the relationship between instances and classes). Relying on the virtualization technology of Docker, it creates independent ports, processes, files and other "space" for the container. Container is a "container" isolated from the host machine. Container hosts can communicate with each other by port, volumes, network and so on.
Repository: Docker's warehouse is similar to git's warehouse, with a warehouse name and tag. After the image is built locally, the image can be distributed through the repository. The commonly used Docker hub includes https://hub.docker.com/, https://cr.console.aliyun.com/ and so on.
Related command
1. Installation
The installation of Docker is very convenient, and there are one-click installation tools or scripts under macOS, ubuntu, etc. For more information, please refer to the official tutorial of Docker.
Click docker in the Terminal after installation, and if the instructions come out, in most cases, the installation has been successful.
two。 Find the basic image
DockerHub and other sites provide a lot of images, usually we will find an image from it as the basic image, and then carry out our follow-up operations.
Here we take the ubuntu basic image as an example to configure a node environment.
Because the link is too long, domestic access to Docker Hub may be slow, and mirror accelerators provided by many domestic manufacturers can be used.
3. Pull the basic image
You can pull the image locally from the relevant hub website by using the docker pull command. At the same time, you can see that the mirror image is pulled according to multiple "layers" in the process of pulling.
> docker pull ubuntu:18.04
With the power of Dockerfile, Docker leaves unlimited possibilities.
What can I do?
Having said all this, what can Docker do in the actual production environment? The commonly used ones may be the following (welcome to add in the comments)
1. Deployment switching in multiple environments
Business development often needs to distinguish between the development environment and the online environment, using Docker to migrate the code and environment in the development environment intact to the online environment, and cooperate with a certain automation process to achieve automatic release.
two。 Front-end cloud building
Because of the egg pain problem of node_modules, different developers in the same warehouse often encounter different people using different package versions and have no idea that they are different from others, which eventually leads to online problems after release. With Docker, you can create new containers in the cloud and build code remotely without pollution and at low cost, so that different people must use the same version.
3. One-click configuration of complex environment
In some scenarios, there may be some super complex environments (for example, freshmen with Java environment). At this time, you can use Docker to encapsulate the environment configuration and directly generate images for everyone to use at low cost.
4. Continuous integration unit testing
Similar to travis-ci
5. Multi-version isolation and file isolation of the same application
For example, this project relies on node6, and that project relies on node 8 (for example, if the hard drive is big enough, it is recommended to solve it through nodeinstall); there are 100 wordpress programs running on the same server (isolation can be established with Docker to prevent mutual contamination).
After reading this article, I believe you have a certain understanding of "how to get started with Docker from 0". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for your reading!
Original link: https://juejin.im/post/5ad3172c5188257ddb10109a
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.