Skip to content

crane: deleted files persist in crane export output #2029

@alexey-igrychev

Description

@alexey-igrychev

Describe the bug

When using crane export to export an image from a registry, deleted files are not ignored despite being removed during the build process.

To Reproduce

  1. Create a Dockerfile with the following commands:

    FROM alpine:3.12
    RUN mkdir -p test
    RUN echo "Hello World" > /test/hello.txt
    RUN rm -rf /test
    RUN mkdir -p /test
    RUN echo "Hello World" > /test/hello2.txt
  2. Start a local registry:

    docker run -d --name=registry --restart=always -e REGISTRY_STORAGE_DELETE_ENABLED=true -p 5000:5000 registry
  3. Build the Docker image:

    docker build -t localhost:5000/test .
  4. Push the image to the local registry:

    docker push localhost:5000/test
  5. Export the image using crane and check for files in the test directory:

    crane export localhost:5000/test - | tar -ztv | grep "test/"
    
    -rw-r--r--  0 0      0          12 Oct 29 22:12 test/hello2.txt
    -rw-r--r--  0 0      0          12 Oct 29 21:45 test/hello.txt
  6. Compare with Docker's export behavior:

    docker run --name test localhost:5000/test
    docker export test | tar -ztv | grep "test/"
    
    drwxr-xr-x  0 0      0           0 Oct 29 22:12 test/
    -rw-r--r--  0 0      0          12 Oct 29 22:12 test/hello2.txt

Expected behavior

crane export should ignore deleted files, consistent with Docker's export behavior.

Additional context

  • Output of crane version: v0.20.2
  • Registry used (e.g., GCR, ECR, Quay): Local registry on localhost:5000

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions