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

fix: Allow to delete images when names of images are short digest ids… #3519

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 19, 2024

  1. fix: Allow to delete images when names of images are short digest ids…

    … of another images.
    
    "nerdctl rmi <REPOSITORY>" can be run to delete the target images.
    
    However, at the current implementation, the deletion fails when images
    names are the short digest ids of another images.
    
    The specific behavior is described below, which is how it works in the
    current implementation.
    
    First, suppose there are alpine and busybox images.
    
        ```
        > nerdctl images
        REPOSITORY    TAG       IMAGE ID        CREATED           PLATFORM       SIZE       BLOB SIZE
        busybox       latest    768e5c6f5cb6    3 seconds ago     linux/arm64    4.092MB    1.845MB
        alpine        latest    beefdbd8a1da    11 seconds ago    linux/arm64    10.46MB    4.09MB
        ```
    
    Then, we tag the alpine image using digest id of the busybox image.
    
        ```
        > nerdctl tag alpine $(dn inspect busybox | jq -rc .[0].RepoDigests[0] | awk -F':' '{print substr($2, 1, 8)}')
    
        > nerdctl images
        REPOSITORY    TAG       IMAGE ID        CREATED          PLATFORM       SIZE       BLOB SIZE
        768e5c6f      latest    beefdbd8a1da    4 seconds ago    linux/arm64    10.46MB    4.09MB
        busybox       latest    768e5c6f5cb6    22 hours ago     linux/arm64    4.092MB    1.845MB
        alpine        latest    beefdbd8a1da    22 hours ago     linux/arm64    10.46MB    4.09MB
        ```
    
    In this situation, running 'nerdctl rmi "$(dn inspect busybox | jq -rc .[0].RepoDigests[0] | awk -F':' '{print substr($2, 1, 8)}')"'
    will fail to remove the image.
    
    The details of the error are as follows.
    
        ```
        > nerdctl rmi "$(dn inspect busybox | jq -rc .[0].RepoDigests[0] | awk -F':' '{print substr($2, 1, 8)}')"
        FATA[0000] 1 errors:
        multiple IDs found with provided prefix: 768e5c6f
        ```
    
    This issue is reported in the following issue.
    
        - containerd#3016
    
    Therefore, this pull request modifies this so that images can be deleted
    with "nerdctl rmi <short digest id of another image>" when images names are
    the short digest ids of another images.
    
    Signed-off-by: Hayato Kiwata <[email protected]>
    haytok committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    c3627e1 View commit details
    Browse the repository at this point in the history