In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what are the mistakes that Docker novices are most likely to make". In daily operation, I believe many people have doubts about the mistakes most likely to be made by Docker novices. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what mistakes are most likely to be made by novice Docker?" Next, please follow the editor to study!
Docker has many advantages, such as:
1. Integration-the operating system, library version, configuration files, applications, etc. are all packaged in a container. This ensures that the image tested by QA will bring the same behavior to the production environment.
2. Lightweight-the memory footprint is so small that only memory is allocated for the main process.
Read fast-start with one click, just as fast as starting the usual linux process.
However, many users still treat containers as common virtual machines and forget an important feature of containers:
Because of this feature, some users need to change their concept of containers. In order to better use and give full play to the value of Docker containers, there are some things that should never be done:
1. Do not store data in a container (container)
The container may be interrupted, replaced, or destroyed. Version 1.0 applications running in a container can easily be replaced by version 1.1 without affecting or causing data loss. Therefore, if you need to store data, store it in a volume (volume). In this case, you should also pay attention to whether the two containers will write data on the same volume, which will lead to corruption. Make sure that the application is suitable for writing to a shared data store.
two。 Don't send the application in two parts. Some people use containers as virtual machines.
So most of them will think that the application should be deployed to an existing running container. This may be true during the development phase that requires constant deployment and debugging, but for QA and production continuous delivery (CD) channels, the application should be part of the mirror. Remember: the container is fleeting.
3. Do not create large mirrors
Large-size images are difficult to assign. Be sure to use only the required files and libraries to run the application. Do not install unnecessary packages and do not run yum update, which downloads a large number of files to the new mirror layer.
4. Do not use single-layer mirroring
To make effective use of the multi-tier file system, always create your own basic mirror layer for the operating system, then create a layer for the user name definition, create a layer for the runtime installation, create a layer for the configuration, and finally create a layer for the application. This makes it easier to recreate, manage, and assign mirrors.
5. Do not create an image from a running container
In other words, do not use the "docker commit" command to create a mirror. This mirror creation method cannot be replicated, so it should be avoided altogether. Always use Dockerfile or any other fully replicable S21 (from source code to mirror) method, so that if you store it in a source control repository (GIT), you can track changes to Dockerfile.
6. Don't just use the "latest version" label
The latest version of the tag is like a "SNAPSHOT" for Maven users. Containers have the basic feature of a multi-tier file system, so we encourage the use of tags. I'm sure no one wants to find out that after months of building an image, the application can't run because the parent layer (that is, the FROM in Dockerfile) is replaced by a new version (which is not backward compatible or the "latest" version retrieved from the build cache is incorrect). You should also avoid using the "latest version" label when deploying containers during production because the currently running mirror version cannot be tracked.
7. Do not run more than one process in a single container
The container works best when running only one process (HTTP daemon, application server, database), but if you run more than one process, you will have a lot of trouble managing and retrieving logs and updating processes separately.
8. Do not store certificates in the mirror and use environment variables
Do not hard-code any username / password in the mirror. Use environment variables to retrieve information from outside the container. Postgres mirroring is an excellent explanation of this principle.
9. Do not run processes with root privileges
"by default, the Docker container runs as root. As Docker technology matures, there are more and more security default options that can be used. Currently, requiring root is dangerous for other users, and not all environments can use root. Images should use the USER directive to specify non-root users for the operation of the container."
10. Don't rely on IP addresses
Each container has its own internal IP address, and if you start and stop the container, the internal IP address may change. If your application or microservice needs to communicate with another container, use environment variables to pass the appropriate hostname and port between containers.
11. Monitoring container Docker
Monitoring has been paid more and more attention by developers, real-time monitoring Docker method, Cloudinsight is recommended here. Unlike some monitoring methods that need to write their own scripts, Cloudinsight, as a free SaaS service, can monitor Docker with one click and has a great visual interface. In addition, Cloudinsight also supports the monitoring of a variety of operating systems, databases, etc., and can display the performance data of all the basic components of the monitored system.
At this point, the study of "what are the most common mistakes made by novice Docker" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.