How to add a data disk to a container service Docker

Source: Internet
Author: User
Tags docker ps

How to add a data disk to a container service Docker

Absrtact: We know that docker data is stored on the disk through a federated file system, and when the number of containers or mirrors that need to run on the machine is increasing, it is possible that the size of the disk will no longer meet the requirements, and that the Docker data directory will need to be expanded by increasing the data disk.

Docker Data Catalog

Docker default container and mirror data store directory is under /var/lib/docker , you can use the DU command to see the size of the disk currently occupied by this directory, for example:

du -H--max-depth=0 /var/lib/Docker7. 9G    /var/lib/docker
Replace the Docker data disk

Because many of the Docker image itself is quite large, so may not be able to use a few mirrors will have a considerable disk footprint, the container will lead to insufficient disk space, this time how to replace the data disk to meet the need to increase the image or container, then the Docker Data directory to add a block of data disk bar.

Purchase the ECS data disk and mount it on the machine that needs to be expanded: 1. Purchase the required configuration Cloud Disk 2 via the ECS console. On the ECS Instance Details page, this instance disk-mounted disk, select the disk you just purchased, and record the mount point /dev/xvd*Or /dev/vd*Log on to the machine and format the disk you just mounted: 1. First, execute on the machine. ls -l /dev/xvd*Or ls -l /dev/vd*See the same disk Id2 as just recorded. Partition the disk with the Fdisk command, and then use the MKFS.EXT4Format the disk, for example:

Move Docker data to the new disk: 1. First stop the Docker daemon, ensure that the data is complete when moving, you can use service docker stopCommand Stop 2. First move the Docker directory to a backup directory, for example: mv /var/lib/docker /var/lib/docker_data3. Then mount the new formatted disk to /var/lib/dockerdirectories, such as: echo "/dev/xvdb1 /var/lib/docker ext4 defaults 0 0" >>/etc/fstab && mkdir /var/lib/docker && mount -a4. Move the previously backed-up Docker data to a new disk, for example: mv /var/lib/docker_data/* /var/lib/docker/Start the Docker daemon and check the data location: 1. Start Docker Daemon, service docker start2. Implementation dfSee the/var/lib/docker mounted on the new disk

3. docker psSee that the container is not missing, restart as needed to start without restart:alwaysContainer for labels

How to add a data disk to a container service Docker

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.