Docker outage Expansion Pool space

Source: Internet
Author: User
Tags docker ps

I use Docker containers here to do the test machine for development use, but as the project increases, some projects require larger hard drives, I pass (http://dl528888.blog.51cto.com/2382721/ 1606170) to dynamically expand the space of the container to meet usage needs, but I am currently setting the Docker pool is not enough (the default pool is 100g, each container gives 10g space), if the pool is full, you cannot create a new container, and cannot delete data to clean up (I use DD to test), so in order to solve this problem, I am prepared to:

1, back up the current container and images;

2, stop the Docker service;

3, the size of the extended pool (from 100g to custom size);

4. Start Docker and restore containers and images.

Here's the information for Docker before backup

09:54:52 # docker versionclient version: 1.1.2client api version:  1.13go version  (client): go1.2.2git commit  (client): d84a070/1.1.2server  version: 1.1.2server api version: 1.13go version  (server): go1.2.2Git  commit  (server): d84a070/1.1.2[email protected]:~09:54:56 # docker  infocontainers: 15images: 10storage driver: devicemapper pool name:  docker-8:3-22676231-pool data file: /var/lib/docker/devicemapper/devicemapper/data  Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata data space used:  95999.2 Mb Data Space Total: 102400.0 Mb Metadata Space  used: 51.4 mb metadata space total: 2048.0 mbexecution driver:  native-0.2kernel version: 2.6.32-431.29.2. el6.x86_64 

You can see that Docker is version 1.1.2, pool is 100g and currently uses 95G

Here is my specific backup procedure

1. Record IP and firewall policies for all containers

My current Docker host uses the default DOCKER0 for bridging, the IP will change after the container restarts, so I can record the IP and firewall policies of all the Docker hosts in order to make it easier to modify the firewall policy

Logging Docker host IPs can be referenced using commands

Docker ps-a|grep-v "NAMES" |awk ' {print $NF} ' |xargs-i {} sh-c "Docker inspect {}|grep-i Add"

Backup firewall Policy

Cp/etc/sysconfig/iptables/tmp/iptables_backup

2. Back up all Docker container

If you extend the pool, the default images and containers will be cleared, so you have to back up

Docker ps-a|grep-v "NAMES" |awk ' {print $NF} ' |xargs-i {} sh-c ' Docker export {} >/tmp/docker_backup/containers/doc Ker_{}.tar "

3, packaging backup all the images

Docker images|grep-v "REPOSITORY" |awk ' {print $ ': ' $ $ ' >docker_images.txt && Docker save-o/tmp/docker_back Up/images/' Cat docker_images.txt|cut-d/-f2 '. Tar ' cat docker_images.txt ' && rm-rf docker_images.txt

4. Stop current Docker all container

Docker stop ' Docker ps-a-Q '

5. Stop Docker Service

/etc/init.d/docker stop

6. Back up old Docker data


Cp-a/var/lib/docker/tmp/docker_backup/data_backup

Backing up data for failed rollback

7. Delete the old Docker database

Rm-rf/var/lib/docker

8. Increase Pool capacity

2 methods, one is to use DD, one is to use the Docker daemon command

Using DD, increase the pool to 600G.

DD If=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/data bs=1g count=0 seek=600

Seek back is the size

Using the Docker daemon

--storage-opt dm.loopdatasize=600g--storage-opt dm.loopmetadatasize=8g

9. Start Docker

/etc/init.d/docker start

10, restore images

Cd/tmp/docker_backup/images/docker Load Test1:new<test1.tar

Use Docker load to restore it one by one

11. Recovery Container

Cd/tmp/docker_backup/containers/cat Test1.tar |docker import-test1:new

12. Start the container and record the IP

In the previous step, the backup container was made into a images, and if you want to start the Docker run, for example, I have a images is test1:new

Docker run--privileged-d--name= "Test1" test1:new/usr/sbin/sshd-d

13. Adjust the firewall

Remember the new container IP and modify it according to the firewall policy of the first step backup

Experience:

If the container is using the default 10g space, the migration is not a problem, but if the container is dynamically expanded, such as the default 10g space, you expand to 30g or higher, then the backup recovery container, the following error occurs

[C3c929fe] +job import (-, Cocos-play,) write/var/lib/docker/devicemapper/mnt/ 19b84c235a7ed914871c0f10b5b17af9fc89955b077ad85afe0ec6e4b253c92b/rootfs/home/www/cocosplay/uploads/neatgame/ Ah2ssp/r_scene_20.cpk:no space left on device

This error is found in Google 2 methods to solve, but I tested, not resolved

The first is that there is not enough physical memory, and the second method is to use a docker temp directory.

Specific issue Reference HTTPS://GITHUB.COM/COREOS/COREOS-VAGRANT/ISSUES/49

Therefore, we recommend that you do not dynamically expand the container disk space, try to use volume to mount.

Another 1.3 and above I test is unable to dynamic expansion of the container space, to the official issue also no one answered, the address is https://github.com/docker/docker/issues/11153

This article is from the "Yin-Technical Exchange" blog, please be sure to keep this source http://dl528888.blog.51cto.com/2382721/1618893

Docker outage Expansion Pool space

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.