The issue is that deleted files in the overlay filesystem don't show as deleted:
During mount, make sure upper fs supports d_type otherwise error out.
In some instances xfs has been created with ftype=0 and there if a
file on lower fs is removed, overlay leaves a whiteout in upper fs but
that whiteout does not get filtered out and is visible to overlayfs
And reason it does not get filtered out because upper filesystem does
not report file type of whiteout as DT_CHR during iterate_dir().
So it seems to be a requirement that upper filesystem support d_type
for overlayfs to work properly. Do this check during mount and fail if
d_type is not supported.
RedHat has documented the requirement:
Note that XFS file systems must be created with the -n ftype=1 option enabled for use as an overlay.
This can have bad results like breaking the ability to delete a directory since the directory can never be emptied. There's also suggestions that it may break the image build. And if anything else goes wrong, docker won't provide any support with that configuration since it's known to cause problems.
From the man page, the option has the following effect:
This feature allows the inode type to be stored in
the directory structure so that the readdir(3) and
getdents(2) do not need to look up the inode to
determine the inode type.
The value is either 0 or 1, with 1 signifying that
filetype information will be stored in the
directory structure. The default value is 1.