Docker Community Forums

Share and learn in the Docker community.

What is the naming conventions of Docker tag?

(Myjrj) #1

What is the naming conventions of Docker tag? It can only contains ‘a…z, A…Z, _/-’ … ?

The Docker site only gives its definition:

Definition of: tag
A tag is a label applied to a Docker image in a repository. Tags are how various images in a repository are distinguished from each other.

(Linus) #2


// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
TagRegexp = match(`[\w][\w.-]{0,127}`)

(Michael Romanchuk) #3

This answers the question, ‘what are the valid characters for a Docker tag?’

A naming convention would be something that specifies where in the tag characters like '-' or '.' should be used, if there are reasons to use 'A' instead of 'a', if certain characters have a special significance, if the position of characters has any implied meaning, etc…

An example would be the naming convention for Debian packages:

If you look at the tags used by the top images in Docker hub, I would say there is an observable pattern, but I haven’t found an actual written convention. The observable pattern seems to be something like this:

tag           := 'latest' | version-info [ '-' distro-info ] | distro-info
version-info  := version-field [ '-' release-label ]
version-field := numeric+ [ '.' version-field ]
release-label := alpha [ alpha-numeric+ ]
distro-info   := alpha+ [ version-info ]

Note: The above definition is not something that can be reliably parsed. I am not defining the above as a good convention. I would define it as an incomplete convention, but better than no convention; possibly a good start. I define it as an observable pattern for tag names.

Note: It is possible that distro-info is actually from-info.

(Matthias Fax) #4

I’ts kind of disappointing that no colons or other special characters are allowed in the tag since the current best practice convention syntax that is even used by Docker images doesn’t give a clear distinction of separate dependency versions and version semantics. It’s a good practice to add dependencies to your tags (e.g., alpine3.8), in case that another image relies on it, but then again, most images also use the hyphen as separator so that you may end up with something like the Docker image “18.09-rc-git”. In this tag, it is unclear if “rc” and “git” are part of the version or represent a separate dependency. If colons were allowed, you would have a clearer tagging. For instance, in the format imagename:imageversion[:depversion(n++)], docker:18.09-rc:gitx.y.z:alpine3.8. That would benefit both the common dependency referencing practice and thus the security of the images, just as the readability of the tags.