Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-squash cannot handle opaque directories #186

Closed
athos-ribeiro opened this issue Sep 30, 2019 · 7 comments · Fixed by #187
Closed

docker-squash cannot handle opaque directories #186

athos-ribeiro opened this issue Sep 30, 2019 · 7 comments · Fixed by #187
Assignees
Milestone

Comments

@athos-ribeiro
Copy link

When the content of a directory is removed, a .wh..wh.opq file is created in that directory to announce thatits (including subdirs and their contents) should be ignored.

Currently, docker-squash just skips those files. This leads to files introduced in lower layers and removed in a top layer to re-appear in the squashed image.

This can be reproduced with:

#!/bin/bash

docker build -t broken-layers:latest - > /dev/null 2>&1 <<EOF
FROM fedora:30

RUN mkdir -p /d1 && touch /d1/foobar
RUN rm -rf /d1 && mkdir -p /d1 && touch /d1/foo
EOF
docker-squash -t broken-layers:squashed broken-layers:latest > /dev/null 2>&1

# Here we can see the content for the squashed image and the non-squashed image are different
echo 'Running `ls /d1` in non-squashed container'
docker run -it --rm broken-layers:latest ls -R /d1
echo 'Running `ls /d1` in squashed container'
docker run -it --rm broken-layers:squashed ls -R /d1
@goldmann
Copy link
Owner

Thank you for this report, I'll take a look at this soon!

@twaugh
Copy link

twaugh commented Oct 10, 2019

Hi, have you had a chance to take a look at this?

@goldmann
Copy link
Owner

@twaugh No, not yet, sorry :( I'll try to squeeze some investigation today (but I have a packed day), if not, then tomorrow.

@goldmann
Copy link
Owner

Thanks for the reproducer, I was able to use it to see the bug.

@goldmann goldmann added this to the 1.0.8 milestone Oct 10, 2019
@goldmann goldmann self-assigned this Oct 10, 2019
@goldmann
Copy link
Owner

I have a fix for this coded locally. I want to look at it next week too to see how it can be improved because I don't like the current appraoch that much.

goldmann added a commit that referenced this issue Oct 14, 2019
Opaque directories are special case whiteout files. In case
an opaque directory is found in a layer, all content inside
of this rectory in this layer should be copied to the squashed
layer, but any content in layers below that layer on the
opaque directory path must be ignored.

Fixes #186
@goldmann
Copy link
Owner

Guys, I would appreciate if you would take a look at the code to find any obvious mistakes. It would be perfect if you could test this release with some image as well.

See #187.

goldmann added a commit that referenced this issue Oct 14, 2019
Opaque directories are special case whiteout files. In case
an opaque directory is found in a layer, all content inside
of this rectory in this layer should be copied to the squashed
layer, but any content in layers below that layer on the
opaque directory path must be ignored.

Fixes #186
goldmann added a commit that referenced this issue Oct 14, 2019
Opaque directories are special case whiteout files. In case
an opaque directory is found in a layer, all content inside
of this rectory in this layer should be copied to the squashed
layer, but any content in layers below that layer on the
opaque directory path must be ignored.

Fixes #186
goldmann added a commit that referenced this issue Oct 14, 2019
Opaque directories are special case whiteout files. In case
an opaque directory is found in a layer, all content inside
of this rectory in this layer should be copied to the squashed
layer, but any content in layers below that layer on the
opaque directory path must be ignored.

Fixes #186
goldmann added a commit that referenced this issue Oct 15, 2019
Opaque directories are special case whiteout files. In case
an opaque directory is found in a layer, all content inside
of this rectory in this layer should be copied to the squashed
layer, but any content in layers below that layer on the
opaque directory path must be ignored.

Fixes #186
@goldmann
Copy link
Owner

Merged, 1.0.8 released and built for Fedora and RHEL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants