Skip to content

Instantly share code, notes, and snippets.

View lautitoti's full-sized avatar

Lautaro Sosa lautitoti

  • Cordoba, Argentina
View GitHub Profile
@lautitoti
lautitoti / docker-registry-image-removal.py
Last active October 20, 2023 15:09
Script to delete images in a private docker registry, older than a year.
import requests
import json
from datetime import datetime, timedelta
def get_tags_older_than_a_year(registry, image, user, password):
url = f"https://{registry}/v2/{image}/tags/list"
response = requests.get(url, auth=(user, password))
if response.status_code == 200:
tags = response.json().get('tags', [])