How to list and delete old docker images?

Bergs 0 Reputation points
2024-08-15T02:21:48.0633333+00:00

We just started using containerization and we're also trying to secure our stuff. Now, we discovered that all of the docker images we pushed have lots of vulnerabilities. Now, after I fixed all of the vulnerabilities and uploaded the clean one, we're still receiving vulnerability reports.vulnerables_repositories

So I assumed that these images are the previous ones. I'm not using tags and always pushed as "latest". In my defense, we have a different Container Registry for each environment which was enforced by the organization, probably for easier billing.

Anyway, I tried to query these images using docker image ls but it seems the older ones don't show up that easily.

Then once I confirmed which images I want to delete, how to perform this delete procedure safely and delete in batch? Thanks!

Azure Container Registry
Azure Container Registry
An Azure service that provides a registry of Docker and Open Container Initiative images.
446 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Srinud 2,235 Reputation points Microsoft Vendor
    2024-08-16T10:00:48.67+00:00

    Hi Bergs,

    When building Docker images, it is essential to provide tag names during the build process.

    If no tags are specified, the default tag "latest" is automatically applied. However, without specific tags, it becomes challenging to distinguish between the latest and previous images.

    To address this, you can rebuild the Docker images with appropriate tags and push them to the Docker registry for vulnerability scanning.

    This approach makes it easier to identify the most recent image.

    If the information is helpful, please consider by clicking the "Accept Answer & Upvote" on the post.

    Thank you.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.