docker-registry磁盘已满,没有想法减肥

时间:2017-01-04 15:56:47

标签: docker docker-registry

我有一个带有docker注册表的服务器,并且已经推了很多次构建相同的:latest标签,现在我的DD已满了,我无法理解它的饮食方式。

磁盘已满

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        48G   45G  397M 100% /
udev             10M     0   10M   0% /dev
tmpfs           794M   81M  713M  11% /run
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/dm-1       9.8G   56M  9.2G   1% /var/lib/docker/devicemapper/mnt/2e895760700ac3e1575e496a4ac6adde4de6129226febba8c0c3126af1655ad9
shm              64M     0   64M   0% /var/lib/docker/containers/5aa47e34d1b8be22deeae473729b4e587e6e4bfe7fb3e262eda891bad4b05042/shm

没有悬空音量也没有图像

# docker volume ls -qf dangling=true
# 
# docker images -f "dangling=true" -q
#  

泊坞窗图片

[root@kvm22:/etc/cron.daily] # docker images 
REPOSITORY                               TAG                 IMAGE ID            CREATED             SIZE
jwilder/nginx-proxy                      0.5.0               72b65b5a6f38        4 weeks ago         248.4 MB
registry                                 2                   c9bd19d022f6        11 weeks ago        33.27 MB
registry                                 2.5                 c9bd19d022f6        11 weeks ago        33.27 MB

磁盘使用情况

 # du -h -d 7 /var/lib/docker/volumes/
12K /var/lib/docker/volumes/24000fbe2e81da06924be8f7ce81e07101824036bca5f87d4d811f2a6f7bfa7b/_data
16K /var/lib/docker/volumes/24000fbe2e81da06924be8f7ce81e07101824036bca5f87d4d811f2a6f7bfa7b
42G /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker/registry/v2/blobs/sha256
42G /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker/registry/v2/blobs
5.9M    /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker/registry/v2/repositories/labor-prod
5.9M    /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker/registry/v2/repositories
43G /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker/registry/v2
43G /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker/registry
43G /var/lib/docker/volumes/registry_docker-registry-volume/_data/docker
43G /var/lib/docker/volumes/registry_docker-registry-volume/_data
43G /var/lib/docker/volumes/registry_docker-registry-volume
43G /var/lib/docker/volumes/

docker version的输出:

# docker --version 
Docker version 1.12.4, build 1564f02

docker info的输出:

# docker info 
Containers: 4
 Running: 1
 Paused: 0
 Stopped: 3
Images: 5
Server Version: 1.12.4
Storage Driver: devicemapper
 Pool Name: docker-8:1-1184923-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: ext4
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 1.058 GB
 Data Space Total: 107.4 GB
 Data Space Available: 3.036 GB
 Metadata Space Used: 2.142 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.145 GB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.90 (2014-09-01)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge null host overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options:
Kernel Version: 3.16.0-4-amd64
Operating System: Debian GNU/Linux 8 (jessie)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.873 GiB
Name: kvm22
ID: G6OC:EKKY:ER4W:3JVZ:25BI:FF2Y:YXVA:RZRR:WPAP:SASB:AJJA:DM6J
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
Insecure Registries:
 127.0.0.0/8

3 个答案:

答案 0 :(得分:4)

我遇到了同样的问题。我无法相信没有现成的解决方案。无论如何,我一起攻击了一个工具,它似乎工作。

您可以在此处找到它:https://github.com/Richie765/docker-tools

基本上它使用bash脚本来找出哪些清单是未标记的。然后通过注册表API删除它们。之后,您可以运行垃圾收集来实际删除数据。

我确定剧本并不完美。欢迎任何改进!

答案 1 :(得分:2)

在这里找到另一个工具。 https://github.com/burnettk/delete-docker-registry-image

包含clean_old_version.py脚本。 我也试一试。

答案 2 :(得分:1)

万一还有人遇到这个问题: 这是我解决问题的“重置”方式:

您可以停止并删除注册表

docker stop registry && docker rm -v registry 

然后重新启动它:

docker run -d -p 5000:5000 --restart=always --name registry registry:2

然后,您将不得不在本地重建图像并将其再次推送到注册表。