docker 镜像磁盘迁移

问题:

在我们使用docker的过程中经常遇到docker 磁盘占满导致docker 容器自动退出问题

解决方案

迁移

1、使用df -h 查找当前系统最大的空闲盘副

[root@Zhpb007 /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        30G   30G  4.3M 100% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G  418M  3.5G  11% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1       497M   81M  417M  17% /boot
/dev/sdb1        40G   49M   38G   1% /mnt/resource
tmpfs           797M     0  797M   0% /run/user/1000
/dev/sdd        197G  3.5G  184G   2% /sdd

2、通过 docker info 查看磁盘当前的信息

[root@Zhpb007 /]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.13.1
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: docker-runc runc
Default Runtime: docker-runc
Init Binary: docker-init
containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: 5eda6f6fd0c2884c2c8e78a6e7119e8d0ecedb77 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-862.11.6.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 3
CPUs: 4
Total Memory: 7.779 GiB
Name: Zhpb007
ID: V5BK:HEZM:4LWH:TNGR:XQP5:R3K3:7BCD:U2P3:SJLM:FZCC:B5LX:EPFO
Docker Root Dir: /mnt/docker/lib
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 hub.docker.powerbridge.com:3333
 127.0.0.0/8
Registry Mirrors:
 https://x7qhhzw3.mirror.aliyuncs.com
Live Restore Enabled: false
Registries: docker.io (secure)

2、systemctl stop docker 完成docker的关停

3、mkdir -p /sdd/docker/lib 创建类似目录(比如home盘最大)

4、rsync -avz /mnt/docker/lib/docker /sdd/docker/lib/ 迁移 /mnt/dockerlib/ 下的文件

5、配置 /etc/systemd/system/docker.service.d/devicemapper.conf。查看 devicemapper.conf 是否存在。如果不存在,就新建

[root@Zhpb007 /]# sudo mkdir -p /etc/systemd/system/docker.service.d/
[root@Zhpb007 /]# 
[root@Zhpb007 /]# sudo vi /etc/systemd/system/docker.service.d/devicemapper.conf
[root@Zhpb007 /]# systemctl daemon-reload
[root@Zhpb007 /]# systemctl daemon-reload
[root@Zhpb007 /]# systemctl restart docker

6、docker version 验证docker是否正常

 

你可能感兴趣的:(Docker)