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 are the five Docker misunderstandings that Java developers need to pay attention to?

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

What are the five Docker misunderstandings that Java developers need to pay attention to? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

How can we use Docker better and more rationally?

Docker has attracted a lot of attention recently, and the reason is obvious. How to successfully deliver the code has been bothering everyone. Traditional container technology is messed up among many requirements and templates. On the other hand, Docker can create containers simply and repeatedly. Using Docker allows you to deliver code faster and more naturally than other containers. Duang,Docker is hot! Then there are some misunderstandings and misunderstandings. Don't be too trusting when others say that Docker works or doesn't work. Thinking about Docker rationally and comprehensively will help you understand whether you really need it or not.

The editor lists five major Docker misunderstandings from the perspective of Java. But first, introduce some background information.

Main misunderstanding 1. Docker is a lightweight virtual machine

This is the main misunderstanding when we first learn Docker. You can be forgiven for this misunderstanding. Docker does look a bit like a virtual machine. Someone on the Docker website even compared the difference between Docker and virtual machines. However, Docker is not really a lightweight virtual machine, but an improved Linux container (LXC). Docker is completely different from a virtual machine. If you use the Docker container as a lightweight virtual machine, you will encounter a lot of problems.

Before using Docker, it is important to understand that there are many fundamental differences between Docker containers and virtual machines.

Resource isolation: Docker does not reach the level of resource isolation that virtual machines can provide. Virtual machine resources are highly isolated, while Docker needs to share some resources from the beginning that Docker cannot isolate and protect, such as page cache and entropy pool. Note: entropy pools are interesting. Entropy pools collect and store random bits generated by system operations. The machine uses this pool when it needs to be randomized (such as password related). If the Docker container occupies these shared resources, other processes will have to wait before these resources are released

Overhead: most people know that the CPU and RAM of virtual machines provide similar performance to physical machines, but there is a lot of additional IO overhead. Because the package of the guest OS,Docker that abandons the virtual machine is smaller, it requires less storage overhead than the virtual machine. But that doesn't mean Docker doesn't have any overhead issues. The Docker container still needs to pay attention to the IO overhead, but it is not as serious as the virtual machine.

Kernel usage: Docker containers and virtual machines are completely different in kernel usage. Each virtual machine uses a kernel. The Docker container shares the kernel among all containers. Sharing the kernel brings some efficiency gains, but at the cost of high availability and redundancy. If a kernel crash occurs in the virtual machine, only the virtual machine on that kernel will be affected. If the kernel of the Docker container crashes, all containers will be affected.

2. Docker makes applications scalable

Because Docker can deploy code on many servers in a very short period of time, some people will naturally feel that Docker makes the application itself extensible. Unfortunately, this is wrong. The code forms the application, and Docker does not rewrite the code. The scalability of the application still depends on the programmer. Using Docker doesn't automatically make your code easy to extend, it just makes it easier to deploy across servers.

3. Docker is widely used in production environment

Because Docker is gaining momentum, many people think that Docker is already widely used in production environments. As a matter of fact, this is wrong. Note that Docker is still a new technology, immature and growing, which means that there are still a lot of annoying bug and lack of functionality. It's true to be interested in new technologies, but it's best to figure out the correct scenarios for the use of new technologies and the areas that require attention and compromise. Now, Docker can be easily applied to the development environment. Many different environments can be easily built with Docker (at least, it gives the impression that different environments can be built), which is useful for development.

In a production environment, the growing pains of new technologies limit the use of scenarios. For example, Docker does not directly support the monitoring of multi-machine networks and resources, which makes it almost impossible to use in a production environment. Of course, there are many potential areas, such as the same package can be deployed directly from the development environment to the production environment. There are also some Docker runtime features that are useful for production environments. But overall, in a production environment, limitations currently outweigh advantages. This is not to say that it cannot be successfully applied to the production environment, but it cannot be expected to be mature and complete at once.

4. Docker is cross-OS.

Another misconception is that Docker works on any operating system and environment. This may come from the analogy of loading and unloading containers, but the relationship between software and operating system is not as direct as the position of the ship.

In fact, Docker is just a technology on Linux. And Docker relies on specific kernel features, so you must have the latest version of the kernel. Based on the differences between different OS, you will encounter serious problems when cross-OS, if you do not use the lowest-level common features. These problems may only occur in 1%, but 1% can also be fatal when you deploy on multiple servers.

Although Docker runs only on Linux, you can also use Docker on OS X or Windows. Using boot2docker runs a Linux virtual machine on an OS X or Windows machine so that Docker can run in that virtual machine.

5. Docker enhances the security of applications

It is also a misunderstanding to think that Docker can improve the security of your code and the process of delivering it. This is also the difference between real containers and containers on software. Docker is a containerization technology that adds an orchestration method. But there are some security vulnerabilities in Linux's container that could be exploited. Docker does not add any security layers or patches to these vulnerabilities. It is not an iron cloth shirt that can protect the application.

From the Java point of view

Docker already has some applications among Java developers. Some features of Docker make it easier to build extensible contexts. Unlike uber-jar, Docker can help you turn all your dependencies (including JVM! Package it into an image that can be released at any time. This is an important feature of Docker that attracts a large number of developers. However, this will also bring some hidden dangers. In general, programmers need to interact with code in different ways-monitor it, debug it, link it, tune it. If you use Docker, all of this will require extra work.

For example, we want to use jconsole, which depends on JMX functionality, and JMX needs a network because it wants to use RMI. Using Docker is not very straightforward, and it takes some skill to open the required port. The problem we first found was that when we wanted to build the Docker installer for Takipi, we had to run a daemon outside of JVM in the container. The detailed solution is on GitHub.

Another serious problem is that the performance tuning of Docker containers is quite difficult. When using containers, you don't know how much memory each container will allocate. If you have 20 containers, memory will be allocated to them in ways that you are not sure about. If you plan to tune the heap size with the parameter-Xmx, it is difficult because the processing of the JVM in the Docker container depends on automatically getting the amount of memory allocated to the container. Performance tuning is almost impossible if you don't even know how much memory is allocated.

Docker is an interesting technology with some real and effective usage scenarios. As an emerging technology, it takes a lot of time to solve the missing functionality and known bug. However, there is a lot of hype in this field. But remember, hype is not a success.

The answers to the five major Docker misunderstandings that Java developers need to pay attention to are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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