In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to modify the storage directory of the image container in docker. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
By default, the default location for Docker images and containers is: / var/lib/docker
In general, we don't give too much under the root partition. There are more and more images and containers. Generally speaking, we have two solutions:
1. Mount a large partition to / var/lib/docker
Generally choose to establish a logical partition lvm to facilitate later expansion of the collective.
Create a new partition and format it
[root@localhost lib] # lvcreate-L 300G lv_docker vg_home [root@localhost lib] # mkfs.ext4 / dev/vg_home/lv__docker
Mount the new partition to the temporary mount point
[root@localhost lib] # mkdir / mnt/docker [root@localhost lib] # mount / dev/vg_home/lv_docker / mnt/docker/
After stopping the docker service, copy the data under / var/lib/docker to the temporary mount point
[root@localhost lib] # service docker stop [root@localhost lib] # cp-r / var/lib/docker/* / mtn/docker
Modify / var/lib/docker to / var/lib/docker.bak and create / var/lib/docker
[root@localhost lib] # mv / var/lib/docker {, .bak} [root@localhost lib] # mkdir / var/lib/docker
Mount the new partition to / var/lib/docker and set up auto-mount on boot
[root@localhost lib] # mount / dev/vg_home/lv_docker / var/lib/docker [root@localhost lib] # vim / etc/fstab--- / dev/vg_home/lv_docker / var/lib/docker ext4 defaults 00 Murray-
Start the Docker service and check whether the Docker service is available and whether the data is complete
[root@localhost lib] # / etc/init.d/docker start [root@localhost lib] # docker images [root@localhost lib] # docker ps-a
Unmount the temporary mount point after confirmation and delete / var/lib/docker.bak
[root@localhost lib] # umount / mnt/docker [root@localhost lib] # rm-rf / var/lib/docker.bak
two。 Modify the storage path of images and containers
Modify the parameters of the image and container storage path in the Docker service configuration file / etc/sysconfig/docker, and add:
Other_args= "--graph=/data/docker"
The specific implementation steps are as follows:
Stop the Docker service
[root@localhost lib] # service docker stop
Backup data to a new storage path
[root@localhost lib] # cp-rf / var/lib/docker / data/
Modify backup / var/lib/docker path
[root@localhost lib] # mv / var/lib/docker {, .bak}
Start the Docker service
[root@localhost lib] # service docker start
Test the Docker service
[root@localhost lib] # docker info Thank you for reading! This is the end of the article on "how to modify the storage directory of the image container in docker". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.