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

crane: deleted files persist in crane export output #2029

Open
alexey-igrychev opened this issue Oct 29, 2024 · 2 comments
Open

crane: deleted files persist in crane export output #2029

alexey-igrychev opened this issue Oct 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@alexey-igrychev
Copy link
Contributor

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
@alexey-igrychev alexey-igrychev added the bug Something isn't working label Oct 29, 2024
@alexey-igrychev
Copy link
Contributor Author

The same issue with crane flatten command:

$ crane flatten localhost:5000/test --tag localhost:5000/test:flatten                                  
2024/10/29 22:32:01 pushed blob: sha256:2c695611fb1e094624385a8e6f26d9617ea095d295fd879088569f69b48e983c
2024/10/29 22:32:01 existing blob: sha256:2c695611fb1e094624385a8e6f26d9617ea095d295fd879088569f69b48e983c
2024/10/29 22:32:01 pushed blob: sha256:472616afd54c24f0d61cd3dd307cae5ae24aaf2b14a527db49bd38bfd8b9c4e5
2024/10/29 22:32:01 localhost:5001/test:flatten: digest: sha256:19b2ab1c17df3c87b88235dc6b54b6f53766801cb56f0a8a3d65361dea25a096 size: 428
localhost:5001/test@sha256:19b2ab1c17df3c87b88235dc6b54b6f53766801cb56f0a8a3d65361dea25a096

$ crane export localhost:5000/test:flatten - | 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

@nabokihms
Copy link

@imjasonh hello! I think we can fix this but firstly need your approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants