Whiteout entries for files from parent image lost by squashing
See original GitHub issueUsing 1.0.0rc5:
If you attempt to remove a file which was in the parent image then squash back to the parent image, the relevant white-outs are lost and the files come back.
Trivial example:
# cat Dockerfile
FROM rhel7
RUN rm -rvf /etc/cron*/*
RUN rm -rvf /etc/logrotate*/*
# docker build --no-cache -t squash-test ./
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM rhel7
---> c453594215e4
Step 2 : RUN rm -rvf /etc/cron*/*
---> Running in e73dc03cd23b
removed '/etc/cron.daily/0yum-daily.cron'
removed '/etc/cron.daily/rhsmd'
removed '/etc/cron.hourly/0yum-hourly.cron'
---> 56b59574af25
Removing intermediate container e73dc03cd23b
Step 3 : RUN rm -rvf /etc/logrotate*/*
---> Running in b307623d18e9
removed '/etc/logrotate.d/subscription-manager'
removed '/etc/logrotate.d/yum'
---> c4b59cb23cc6
Removing intermediate container b307623d18e9
Successfully built c4b59cb23cc6
# docker-squash -f rhel7 -t squash-test:squashed squash-test
2016-05-31 09:55:32,130 root INFO docker-squash version 1.0.0rc5, Docker 78ee77d/1.9.1, API 1.21...
2016-05-31 09:55:32,131 root INFO Using v1 image format
2016-05-31 09:55:32,140 root INFO Old image has 3 layers
2016-05-31 09:55:32,143 root INFO Checking if squashing is necessary...
2016-05-31 09:55:32,143 root INFO Attempting to squash last 2 layers...
2016-05-31 09:55:32,143 root INFO Saving image c4b59cb23cc602d0f11ddf31dda32c17d02793fed6197c42dd812669b108c4c8 to /tmp/docker-squash-HYqT55/old/image.tar file...
2016-05-31 09:55:42,532 root INFO Image saved!
2016-05-31 09:55:42,533 root INFO Unpacking /tmp/docker-squash-HYqT55/old/image.tar tar file to /tmp/docker-squash-HYqT55/old directory
2016-05-31 09:55:42,995 root INFO Archive unpacked!
2016-05-31 09:55:43,041 root INFO Squashing image 'squash-test'...
2016-05-31 09:55:43,042 root INFO Starting squashing...
2016-05-31 09:55:43,042 root INFO Squashing file '/tmp/docker-squash-HYqT55/old/c4b59cb23cc602d0f11ddf31dda32c17d02793fed6197c42dd812669b108c4c8/layer.tar'...
2016-05-31 09:55:43,043 root INFO Squashing file '/tmp/docker-squash-HYqT55/old/56b59574af2578b0757055151f1655e6ae3d1fd89115870ce2f68e866ad2a5f3/layer.tar'...
2016-05-31 09:55:44,037 root INFO Squashing finished!
2016-05-31 09:55:44,038 root INFO New squashed image ID is b69cec34b4ddf09a80e04921e0a9dcfde0adff65aeb1c665f8a496ff900f10f5
2016-05-31 09:55:46,689 root INFO Image registered in Docker daemon as squash-test:squashed
2016-05-31 09:55:46,731 root INFO Done
# docker run -t -i --rm=true squash-test
[root@3fb0f5b1e8fd /]# ls /etc/cron.*
/etc/cron.daily:
/etc/cron.hourly:
# docker run -t -i --rm=true squash-test:squashed
[root@7ccd53847399 /]# ls /etc/cron.*
/etc/cron.daily:
0yum-daily.cron rhsmd
/etc/cron.hourly:
0yum-hourly.cron
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Squashed image is different from original · Issue #23 - GitHub
I am squashing an image based in python:2.7 and after the squash python ... files ('whiteout' files, docker's internal marker for a deleted...
Read more >Interpreting whiteout files in Docker image layers
Interpreting whiteout files in Docker image layers. I've been playing again with Docker images and their internal layers a little more over the ......
Read more >Squashing Docker Images · - Jason Wilder's Blog ·
A common problem when building docker images is that they can get big quickly. A base image can be a tens to hundreds...
Read more >Best practices for writing Dockerfiles - Docker Documentation
This document covers recommended best practices and methods for building efficient images. Docker builds images automatically by reading the instructions from a ...
Read more >The Twitter Files, leaks and the FBI: key revelations so far
The Twitter Files began on December 2 after CEO Elon Musk promised to ... removed posts for Biden campaign and shadow banned conservatives....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

After long try and fail, I do have a hacky way to fix this. Working now to make it suitable for a PR.
I’ve tried your example and this is what I got:
For me it looks the same 😃