exclude yum apt pip etc cache files
kenotsolutions opened this issue · comments
cat Dockerfile
FROM centos:7
# Install python & git
RUN \
yum install -y python36 python36-libs python36-devel python36-pip git && \
yum clean all
# Upgrade pip
RUN pip3.6 install --upgrade pip
WORKDIR /app
ENV PYTHONPATH=/app/
ADD requirements.txt .
RUN pip3.6 install -r requirements.txt
ADD code /app/code
ADD run .
CMD /app/run
cat requirements.txt
certifi==2020.6.20 # via requests
chardet==3.0.4 # via requests
idna==2.9 # via requests
pyjwt==1.7.1
When I check the previously created image with the new one with I see lots of "cache/yum/usr etc" files changes. Is there a way to exclude these cache files?
These two images exactly the same. Because of installing some packages and the packages cache's files could be different and the result shows these images are not equal.
Actual behavior
container_diff diff first-image:v-1 first-image:v-2- --type file
FILE SIZE1 SIZE2
/root/.cache/pip/http/f/5/1/e/b/f51eb05b6872485842f39da1d7ef12653098ebec7b77041b388618b5 1.4M 1.4M
/root/.cache/pip/http/2/e/4/6/2/2e46276f550f6c2631aaada6d9470e7e78f4582e5f6ee831a9abc0cf 1.1M 1.1M
/root/.cache/pip/http/1/b/1/d/5/1b1d598f94c6395d6580f16eb5064e6185f74cc12655db0af3352e77 247.5K 247.5K
/root/.cache/pip/http/d/e/4/3/7/de437938ef85929246af957191da12fbc37876e8e6bf1a090f59e1d8 179.9K 179.9K
/root/.cache/pip/http/a/0/1/5/6/a015691fb2a211192a5b13e4060e87c3707966d77ccc8262a8531b66 146.1K 146.1K
/root/.cache/pip/http/b/f/d/6/3/bfd6322b8f4c82d6b7ed54608512187e126478b3b0851b74973f4adc 143.1K 143.1K
/usr/local/lib/python3.6/site-packages/pip/_vendor/certifi/__pycache__/__init__.cpython-36.pyc 226B 226B
/usr/local/lib/python3.6/site-packages/pip/_internal/cli/__pycache__/__init__.cpython-36.pyc 223B 223B
/usr/local/lib/python3.6/site-packages/pip/_internal/models/__pycache__/__init__.cpython-36.pyc 211B 211B
/usr/local/lib/python3.6/site-packages/pip/_internal/operations/install/__pycache__/__init__.cpython-36.pyc 211B 211B
/
/var/lib/yum/yumdb/r/0173fc7c52ef50afdb5137f1da1ba5206b42ccca-redhat-rpm-config-9.1.0-88.el7.centos-noarch/origin_url 114B 114B
/var/lib/yum/yumdb/p/aff1b7a90f04974419edaddfddd296a104400e12-perl-Scalar-List-Utils-1.27-248.el7-x86_64/origin_url 112B 112B
/var/lib/yum/yumdb/p/73a511b40005b79835db73cce4888366f7f55e6b-python3-setuptools-39.2.0-10.el7-noarch/origin_url 109B 109B
/var/lib/yum/yumdb/p/fdc208801104eb7f9c7e4402644979b96d878644-perl-Text-ParseWords-3.29-4.el7-noarch/origin_url 108B 108B
/var/l
Expected behavior
exclude the yum, apt pip etc installation cache files
Information
- container-diff version: v0.15.0 built from git 2db6995
- Operating system: centos
Steps to reproduce the behavior
- docker build -t first-image:v-1 .
- docker build -t first-image:v-2 .
- container_diff diff first-image:v-1 first-image:v-2 --type file
container_diff diff first-image:v-1 first-image:v-2
SIZE1 SIZE2
493.2M 493.2M
container_diff diff first-image:v-1 first-image:v-2 --type file
/var/lib/yum/yumdb/p/10a2bcaf5354aed44d527ba1bdac29080f705ec4-perl-Git-1.8.3.1-23.el7_8-noarch/origin_url 97B 100B
/var/lib/yum/yumdb/f/cb7e013b0931dc495c9295d40ffbd0f49e31484b-fipscheck-lib-1.4.1-6.el7-x86_64/origin_url 97B 100B
/var/lib/yum/yumdb/p/ce0324e97e07d3d1d01ee9e58059ce62fb775862-perl-parent-0.225-244.el7-noarch/origin_url 97B 100B
/var/lib/yum/yumdb/p/c43e721cef394ab0d7e9c1a4478cf4bb708616e6-perl-constant-1.27-2.el7-noarch/origin_url 96B 99B
/var/lib/yum/yumdb/p/9a4645dbcd38f82e138a1e6c3b62ff84a392c1ee-perl-Storable-2.45-3.el7-x86_64/origin_url 96B 99B
/var/lib/yum/yumdb/p/3ed43b94b44195d07ab8e986c1ba1cfab5dfa01f-perl-Exporter-5.68-3.el7-noarch/origin_url 96B 99B
/var/lib/yum/yumdb/p/fe1d5c9cb23116e05d8a9f2b535009ddfbca7709-perl-Error-0.17020-2.el7-noarch/origin_url 96B 99B
/var/lib/yum/yumdb/p/bb641aaaa5b9049e167882316e2d7f0b2b818c8c-perl-libs-5.16.3-297.el7-x86_64/origin_url 96B 99B
/var/lib/yum/yumdb/p/aacd2bc687f6e39a172fc1ca36d0907ddc196b09-perl-srpm-macros-1-8.el7-noarch/origin_url 96B 99B
/var/lib/yum/yumdb/p/70c9828249db3211971c602ffe8c6aae9ebbbfb4-perl-Socket-2.010-5.el7-x86_64/origin_url 95B 98B
/var/lib/yum/yumdb/p/be54ffa2af8a5a9beeae1064c7c572d18b640dd4-python3-pip-9.0.3-8.el7-noarch/origin_url 95B 98B
/var/lib/yum/yumdb/l/6d9ff07a8e9a07e3eb3b1e8d11a8cdc87136ce75-libtirpc-0.2.4-0.16.el7-x86_64/origin_url 95B 98B
/var/lib/yum/yumdb/p/78b5e47f739730bb13d2d2e9209e7d976d52076c-perl-threads-1.87-4.el7-x86_64/origin_url 95B 98B
/var/lib/yum/yumdb/g/eb374516d73b1ab650b0a6d52e636687932ff61d-groff-base-1.22.2-8.el7-x86_64/origin_url 95B 98B
/var/lib/yum/yumdb/p/f9c3f999a602254fb22b091f3f459318d4a4f0cd-perl-Filter-1.49-3.el7-x86_64/origin_url 94B 97B
/var/lib/yum/yumdb/p/f8210114c81bcd85c1e508f9fa4f9e881d0f4501-perl-Encode-2.51-7.el7-x86_64/origin_url 94B 97B
/var/lib/yum/yumdb/p/e1b55081ba64e0b1ddc03530443cf7631d8c4bfb-perl-Carp-1.26-244.el7-noarch/origin_url 94B 97B
/var/lib/yum/yumdb/f/b3411b91c4f4f9ac6441f0f8643d20fc15afc6b1-fipscheck-1.4.1-6.el7-x86_64/origin_url 93B 96B
/var/lib/yum/yumdb/o/36f22dbc9f95738798fcab22f664a1527f24d9e3-openssh-7.4p1-21.el7-x86_64/origin_url 92B 95B
/var/lib/yum/yumdb/g/fbb937c7f81015f30779d42f608a474f8e9b0390-git-1.8.3.1-23.el7_8-x86_64/origin_url 92B 95B
/var/lib/yum/yumdb/p/f7fb4b9edf49a27154378b606309189516da7ce2-perl-5.16.3-297.el7-x86_64/origin_url 91B 94B
/var/lib/yum/yumdb/r/5e86826da9a304d6919bb712cca6ca2008ceeefc-rsync-3.1.2-10.el7-x86_64/origin_url 90B 93B
/var/lib/yum/yumdb/l/6ade2b6d06cbed6f2eb46239f31b92b37fdb78fb-less-458-9.el7-x86_64/origin_url 86B 89B
/var/lib/yum/yumdb/z/ccee29b0ebdbefdec09bb543d7ef43882836c1da-zip-3.0-11.el7-x86_64/origin_url 86B 89B
/var/lib/yum/yumdb/d/471afb1caecfb304d6fb7dc27f5810d8f7714c4b-dwz-0.11-3.el7-x86_64/origin_url 86B 89B
/root/.cache/pip/selfcheck/241e69162522ccf5846a2f42ebc24b17464915a155679666b89a9f31 74B 74B
/root/.cache/pip/selfcheck.json 70B 70B
@kenotsolutions thanks for the issue! this seems like a reasonable request, but I likely won't be able to get to this any time soon since I'm not really actively working on this project anymore. contributions are certainly welcome though if you'd like to take a stab at fixing it!
@nkubala I used jq here.
container_diff diff first-image:v-1 first-image:v-2- --type file --json |jq -c '.[].Diff| .Mods[]? |select( .Name | contains("/var/lib/yum/")|not) |select( .Name | contains("/usr/local/lib/python3.6/site-packages/pip/")|not)'