"docker images" command doesn't show correct size -
i've built image using dockerfile in repo , since make
on opencv source files image size increases 3.1 gb. so, in order reduce size of image removed source , build files after installing opencv , if check size of image show size has reduced when check using docker images
command size remains same.
here's output docker build
run echo "size of image before installing opencv" ---> using cache ---> 6408d5fde660 step 11 : run echo `du -sh /` ---> running in 70e945c95f0c 1.9g / ---> 60f80a0d27e6 removing intermediate container 70e945c95f0c step 12 : run cd ~/ && git clone...... step 14 : run echo "size of image after installing opencv" ---> using cache ---> 1e065271efa7 step 15 : run echo `du -sh /` ---> running in 0f82de699dd9 5.9g / ---> a90660ac1f25 removing intermediate container 0f82de699dd9 step 16 : run echo "size of opencv source , build directories" ---> running in 7412b1e468e8 size of opencv source , build directories ---> 252b6d0ef5b7 removing intermediate container 7412b1e468e8 step 17 : run echo `du -sh ~/opencv*` ---> running in 8fddb31f4770 3.8g /root/opencv 218m /root/opencv_contrib ---> 3f9c355fec15 removing intermediate container 8fddb31f4770 step 18 : run rm -rf ~/opencv* # removes ---> running in 8a6c823f5675 ---> 96af8b3d01bf removing intermediate container 8a6c823f5675 step 19 : run echo "size of image after removing opencv source , build directories" ---> running in e292c233f8db size of image after removing opencv source , build directories ---> b08582019c1b removing intermediate container e292c233f8db step 20 : run echo `du -sh ~/opencv*` ---> running in 9cb62f3be3b3 du: cannot access '/root/opencv*': no such file or directory ---> 74473a783265 removing intermediate container 9cb62f3be3b3 step 21 : run echo `du -sh /` ---> running in 45c9fcedf650 1.9g / ---> 0350a13a1a3b removing intermediate container 45c9fcedf650 built 0350a13a1a3b
from last step looks image size should 1.9gb when docker images
shows me 6.298 gb
➜ d1 docker images repository tag image id created size ubuntu_py latest 0350a13a1a3b 11 seconds ago 6.298 gb
even container size shown correctly,
➜ d1 docker run -it ubuntu_py /bin/bash root@b549d9716e19:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@b549d9716e19:/# du -sh 1.9g . root@b549d9716e19:/#
docker layers immutable. once it's created, it's there stay. if want build remove cruft used build need things in same run
command or it's going layer everything.
edit: in fact, it's going have marginally worse effect delete files are, you're adding additional layer docker has whiteout files want delete, increasing size :p
Comments
Post a Comment