尝试将docker容器提交到映像时出错:
[root@dockerregistry /]# docker commit da4180ab1536 dockerregistry:5000/myimage
Error response from daemon: max depth exceeded
它确实有很多以前提交的层次:
[root@dockerregistry /]# docker history dockerregistry:5000/myimage
IMAGE CREATED CREATED BY SIZE COMMENT
b0922c490bf2 30 hours ago su - jenkins -c cd /home/jenkins/sources/ ; f 161.7 kB
91f441d37f9b 2 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 75.05 kB
ac9669a5bd76 2 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 63.68 kB
080c3d024017 2 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 120.3 kB
08a505cc4654 2 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 102.8 kB
b9babd91b9e2 3 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 237 kB
4822b25109da 4 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 594.1 kB
5a2511c28162 5 days ago bash 96.84 MB
<missing> 5 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 341.3 kB
<missing> 5 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 1.037 MB
<missing> 6 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 230.9 kB
<missing> 7 days ago su - jenkins -c cd /home/jenkins/sources/ ; f 394 kB
.....
.....
.....
<missing> 3 months ago bash 98.68 MB
<missing> 3 months ago bash 417.3 MB
<missing> 3 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 3 months ago /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$/ 1.895 kB
<missing> 3 months ago /bin/sh -c rm -rf /var/lib/apt/lists/* 0 B
<missing> 3 months ago /bin/sh -c set -xe && echo '#!/bin/sh' > /u 745 B
<missing> 3 months ago /bin/sh -c #(nop) ADD file:fdbd881d78f9d7d924 124.8 MB
[root@dockerregistry /]# docker history dockerregistry:5000/myimage | wc -l
130
我知道有125层的限制,但也许有一种解决方法可以粘合/合并所有图层或提交为没有历史层的新图像?
答案 0 :(得分:0)
答案 1 :(得分:0)
这完全符合我的要求:https://github.com/goldmann/docker-squash
[root@dockerregistry ~]# docker-squash dockerregistry:5000/myimage
2016-11-15 13:46:43,959 root INFO docker-squash version 1.0.4, Docker 23cf638, API 1.24...
2016-11-15 13:46:43,960 root INFO Using v2 image format
2016-11-15 13:46:44,041 root INFO Old image has 129 layers
2016-11-15 13:46:44,041 root INFO Checking if squashing is necessary...
2016-11-15 13:46:44,041 root INFO Attempting to squash last 129 layers...
2016-11-15 13:46:44,041 root INFO Saving image sha256:b0922c490bf2c519837f07310be274497b4754f15db8fcfc3ebefa8c94ce5d29 to /tmp/docker-squash-kdP5fu/old/image.tar file...
2016-11-15 13:49:28,588 root INFO Image saved!
2016-11-15 13:49:28,590 root INFO Unpacking /tmp/docker-squash-kdP5fu/old/image.tar tar file to /tmp/docker-squash-kdP5fu/old directory
2016-11-15 13:49:50,222 root INFO Archive unpacked!
2016-11-15 13:49:50,603 root INFO Squashing image 'dockerregistry:5000/myimage'...
2016-11-15 13:49:50,607 root INFO Starting squashing...
2016-11-15 13:49:50,607 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/dd8d761bd33f83bc7df9b566728e384ac3034c5cb6ca48696b09a5b83cc6b410/layer.tar'...
2016-11-15 13:49:50,634 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/b725434299be967c144e47256cf83163a69d2ae7954d6e7200ea7bd581a85709/layer.tar'...
2016-11-15 13:49:50,643 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/43911000835aaf76e08826dba82a3f5be4356f88188b8ee5b1c4fe70770b395d/layer.tar'...
2016-11-15 13:49:50,656 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/a798a4625590e8b60756d816ae18a4edb3e42b43b2147de926daaa77c13fe8e6/layer.tar'...
2016-11-15 13:49:50,665 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/2ae62947e6e2fa56dab068de5b8432ed4da1c87ffe8e0c66bab6a7e3d4f968bf/layer.tar'...
2016-11-15 13:49:50,701 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/c418fec128087d2a4ff92bdf844e925c162fdd42ffc0ddacf48057e2b8de638e/layer.tar'...
2016-11-15 13:49:50,707 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/0fa8e0bce3ee4966591a155a9cebe903033069bf03d0b0704ec6e3cd4b618c60/layer.tar'...
2016-11-15 13:49:50,822 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/446296f2558316b26d02723a77e7f19456322981826919cc2af70e8b1fb60e31/layer.tar'...
2016-11-15 13:49:52,079 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/894b9a9d5e5ec9ac874b482d46cd262b5216e05f8e6bec34f3f92d7735eaa1c1/layer.tar'...
2016-11-15 13:49:52,095 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/0c2b81763fd59c1c7e8bbd03bbaef75bbbe59604e089c2de677280a185c8eaad/layer.tar'...
2016-11-15 13:49:52,187 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/c4f1902182a78671ea3807d45968c0e7f92d2570eef7cdb35b8c9a922a996977/layer.tar'...
2016-11-15 13:49:52,249 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/f5b9106aa39907afec2c9623c9bff0b18ab3b9bd3b1b6b7222b9a068de9087d2/layer.tar'...
2016-11-15 13:49:52,283 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/d4ef2dcd76df27c76a4cf41a600238c84d3fbad8d7f79adcfccf03e2a922ef4e/layer.tar'...
2016-11-15 13:49:52,304 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/749e443a4f0280d6c3d9adafb1f9554b76718104bb947d0cade65b79ad037d7a/layer.tar'...
2016-11-15 13:49:52,340 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/bc121fe4b944d3d4787b510c656c7bc9ccc8b2118c652a9a86226e4cb4ac6b2d/layer.tar'...
2016-11-15 13:49:52,427 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/677cbc6ef962ef25911f6e0a64109644d488e52512c262418b99424aabc986ea/layer.tar'...
2016-11-15 13:49:52,571 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/bb70089be4dd4bc7c71cb1b7db90ca82819fe6931be030b157d574d8126c7edf/layer.tar'...
2016-11-15 13:49:52,671 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/f820a2451c30c588a41f99ad21b54c353361e9165531e75287c6a24ae38babd8/layer.tar'...
2016-11-15 13:49:52,679 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/8fa382dc54ae8d066b8829da21bfb4d8308a4682d666efb5f396d58adc0543ec/layer.tar'...
2016-11-15 13:49:52,686 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/df8caa134dd62aa8f027007bf6db976ffbce4fc228e6e31754e1b55b745f3520/layer.tar'...
2016-11-15 13:49:52,694 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/129440a7c26dc55216e396d4f41ecadae3dd715a650d720a1dd0c0a09643d7b9/layer.tar'...
2016-11-15 13:49:52,712 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/1d50c9538b1b2d6fa8869f63fd05037f79d41dc59dd573f8b321274d486d64a5/layer.tar'...
2016-11-15 13:49:52,742 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/fbac6b355da86ce7c201a2cad40cfda768eb28e7854fdeda3bfd6200b823d691/layer.tar'...
2016-11-15 13:49:52,750 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/8bd4c828ef42310152c227c12a42c50138fdde86f276b94f5f5a684ac6a68650/layer.tar'...
2016-11-15 13:49:52,758 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/e3550c095341649e0735c6d573a584c68a7b46c71215449f5d427c53f69b821a/layer.tar'...
2016-11-15 13:49:52,766 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/e77c3c0a400dc77adb6407966d54e078368e73f3dd75d1785aed986a5a68be6d/layer.tar'...
2016-11-15 13:49:52,775 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/2fb62e3ff9757e96954dd0216b2cc7c0d42cc6e72b9cfe32017406db21c23a0c/layer.tar'...
2016-11-15 13:49:52,794 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/10f85ad9a980934a53d9d4413d007d89365875c5dd2d12ef6165860bb85c0d79/layer.tar'...
2016-11-15 13:49:52,795 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/10942ac55066dc1507ad96c9a0b42d22b62932dcdd38e5b3e548796daf563bf3/layer.tar'...
2016-11-15 13:49:52,821 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/bf70566f3b9287205e258b697e4d30ab0a80d8a398db2420867d440bd225150a/layer.tar'...
.......
.......
.......
2016-11-15 13:56:01,980 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/23f4dd896c9fe0ee186685186510efb77ed72725c82ae715619d793c081a7e10/layer.tar'...
2016-11-15 13:56:02,101 root INFO Squashing file '/tmp/docker-squash-kdP5fu/old/2b8a5cc36c07cfb2a5bd6e40f9d5dd52fb300ab1a7afb6e22b3d977e3cfcb885/layer.tar'...
2016-11-15 13:57:25,656 root INFO Squashing finished!
2016-11-15 13:58:03,350 root INFO New squashed image ID is 952b5920893672d6500a9f66f3ed3ab382fa709178ef429aaf0dcd47b188ab81
2016-11-15 14:00:28,544 root INFO Done