GoogleContainerTools / container-diff

container-diff: Diff your Docker containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

container-diff doesn't handle case-insensitive filesystems well

SeanHood opened this issue · comments

Expected behavior

container-diff should work on case-insensitive filesystems, or detect and flag that there was an issue to the user

Actual behavior

container-diff returns an error like:

ERRO[0000] error removing file /Users/seanhood/.container-diff/cache/daemon_container-diff-case/foo/file.txt
ERRO[0000] error retrieving image daemon://container-diff-case: getting filesystem for image: remove /Users/seanhood/.container-diff/cache/daemon_container-diff-case/foo/file.txt: not a directory

Information

  • container-diff version: v0.17.0 built from git bea7ad9
  • Operating system: macOS 11.1 (Big Sur)

Steps to reproduce the behavior

  1. Create a docker image from the following Dockerfile

    FROM alpine
    
    RUN mkdir /foo/
    RUN touch /foo/file.txt
    RUN touch /Foo
    
  2. Build the repro image: docker build . -t container-diff-case

  3. Run container-diff analyze:

    $ container-diff analyze daemon://container-diff-case -v debug
    INFO[0000] retrieving image: daemon://container-diff-case
    INFO[0000] retrieving local image ref took 0.174155 seconds
    INFO[0000] time elapsed retrieving image digest: 0.126638s
    INFO[0000] caching filesystem at /Users/seanhood/.container-diff/cache/daemon_container-diff-case
    DEBU[0000] Creating file /Users/seanhood/.container-diff/cache/daemon_container-diff-case/Foo with permissions -rw-r--r--
    DEBU[0000] Creating directory /Users/seanhood/.container-diff/cache/daemon_container-diff-case/etc with permissions drwxr-xr-x
    DEBU[0000] Removing /Users/seanhood/.container-diff/cache/daemon_container-diff-case/foo/file.txt for overwrite
    ERRO[0000] error removing file /Users/seanhood/.container-diff/cache/daemon_container-diff-case/foo/file.txt
    ERRO[0000] error retrieving image daemon://container-diff-case: getting filesystem for image: remove /Users/seanhood/.container-diff/cache/daemon_container-diff-case/foo/file.txt: not a directory
  4. Running a second time "appears" to work

    $ container-diff analyze daemon://container-diff-case -v debug
    INFO[0000] retrieving image: daemon://container-diff-case
    INFO[0000] retrieving local image ref took 0.172712 seconds
    INFO[0000] time elapsed retrieving image digest: 0.133851s
    INFO[0000] using cached filesystem in /Users/seanhood/.container-diff/cache/daemon_container-diff-case
    INFO[0000] retrieving analyses
    
    -----Size-----
    
    Analysis for container-diff-case:
    IMAGE                      DIGEST                                                                         SIZE
    container-diff-case        sha256:608ae652d286192c1c2b6bc1d77c63e6f565f2d6cd70d9c2c7b33d9c7402c228        0
    
  5. Files in the cache dir:

    $ ls -l /Users/seanhood/.container-diff/cache/daemon_container-diff-case/
    total 0
    -rw-r--r--  1 seanhood  staff   0  8 Dec 21:27 Foo
    drwxr-xr-x  2 seanhood  staff  64  8 Dec 21:27 etc
    

Workaround (at least for macOS):

Create a volume:

hdiutil create -size 20g -fs 'Case-sensitive Journaled HFS+' -volname ContainerDiff ~/ContainerDiff.dmg
hdiutil unmount ContainerDiff.dmg

Use volume:

container-diff diff -c /Volumes/ContainerDiff <image> <image>