In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to reduce the current docker container size", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to reduce the current container size of docker.
When building docker containers, you should try to get smaller images as much as possible, because smaller images are faster to transfer and deploy. The Docker default space size is divided into two, one is the pool space size, and the other is the container space size.
Therefore, the size of the modified space is also divided into two. Here you use yum under centos to install Docker.
First of all, to change the space size, it is necessary to make Docker run in the daemon environment, that is, to stop the running docker service first.
Service docker stop
Then use the command to run docker in the daemon environment
Docker-d
1. Modify the pool space size method:
Dd if=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/data bs=1G count=0 seek=1000dd if=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/metadata bs=1G count=0 seek=10
The above 1000 is the 1TB size, that is, the datapool space size is 1TB, and 10 is the space size of Metadata, 10GB
After running, use the command to view the docker pool space size:
Docker info
two。 Modify the container space size:
First go to the directory (the default directory for installing docker using yum)
Cd / dev/mapper/
Use the command to see if the container is running
Docker ps-a
Use the command to view container volumes
Dmsetup table
You can see 20971520, and this is the volume space value, and that's what we need to modify here.
Other values should be written down: 253VR 7 11
Use the ls or ll command to see if the files in the / dev/mapper/ directory exist. (this is important because a Container that is not running will not have this file.)
Use the command to modify the container space size:
Echo 0 88080384 thin 253 dmsetup load docker-253:1 7 11 | dmsetup load docker-253:1-184549824-95f242e4fe2fef132ab1a706ebf8eecbb1c6db19547c3f12b34b76a5dee96c7e
The 88080384 here replaces the original value of 20971520, which means: 42GB.
The counting formula is: 42 "1024" 1024 "1024" 512
You can use the command to print:
Echo $((42, 1024, 1024, 1024))
Then use the command:
Dmsetup resume docker-253:1-184549824-95f242e4fe2fef132ab1a706ebf8eecbb1c6db19547c3f12b34b76a5dee96c7eresize2fs / dev/mapper/docker-253:1-184549824-95f242e4fe2fef132ab1a706ebf8eecbb1c6db19547c3f12b34b76a5dee96c7e
Done. Then enter the terminal of the container and use the command df-h to see the modified container space.
At this point, I believe you have a deeper understanding of "how to reduce the current container size of docker". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.