google / google/go-containerregistry
crane: deleted files persist in crane export output
- Dominant language
- Go
- Stars
- 4k
- Forks
- 686
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 26
Description
### 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:
```Dockerfile
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:
```bash
docker run -d --name=registry --restart=always -e REGISTRY_STORAGE_DELETE_ENABLED=true -p 5000:5000 registry
```
3. Build the Docker image:
```bash
docker build -t localhost:5000/test .
```
4. Push the image to the local registry:
```bash
docker push localhost:5000/test
```
5. Export the image using `crane` and check for files in the `test` directory:
```bash
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:
```bash
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`
Contributor guide
Research direction
The issue names no implementation files or tests. Start at the crane export command, reproduce the case with the supplied Dockerfile and local registry, and trace how deleted files from image layers are handled. Done means the exported archive omits test/hello.txt and matches Docker's export behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100