Skip to content

utils

sanitize_image_name

sanitize_image_name(image_name, tag='latest')

Sanitizes the image name according to the Docker spec.

The tag must be valid ASCII and can contain lowercase and uppercase
letters, digits, underscores, periods, and hyphens. It cannot start
with a period or hyphen and must be no longer than 128 characters.

Parameters:

Name Type Description Default
image_name str

The name of the image to sanitize, without the tag component.

required
tag str

The tag of the image.

'latest'

Returns:

Type Description
str

The full sanitized image tag suitable for use with docker tag, etc.