distribution: Docker tags are not compatible with semver
Docker tags are not allowed to have the the + (build metadata separator) character, meaning they can’t hold the full range of semver compatible version strings. See §10 of the semver v2.0.0 spec: http://semver.org
When I try to use a plus character, this happens…
$ docker tag some-image blah:0.0.0+1
Error response from daemon: Illegal tag name (0.0.0+1): only [A-Za-z0-9_.-] are allowed ('.' and '-' are NOT allowed in the initial), minimum 1, maximum 128 in length
You can see the code which defines an allowed tag name at https://github.com/docker/distribution/blob/master/reference/regexp.go#L25
This is a bit frustrating, as I want to use semver in my tags. Is there any specific reason why the plus character is disallowed in the tag? If not, can we add support for it? I’d be happy to send a PR…
$ docker version
Client:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Thu Sep 10 19:10:10 UTC 2015
OS/Arch: darwin/amd64
Server:
Version: 1.8.2
API version: 1.20
Go version: go1.4.2
Git commit: 0a8c2e3
Built: Thu Sep 10 19:10:10 UTC 2015
OS/Arch: linux/amd64
$ docker info
Containers: 37
Images: 180
Storage Driver: aufs
Root Dir: /mnt/sda1/var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 254
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.0.9-boot2docker
Operating System: Boot2Docker 1.8.2 (TCL 6.4); master : aba6192 - Thu Sep 10 20:58:17 UTC 2015
CPUs: 1
Total Memory: 996.2 MiB
Name: dev
ID: J5RR:6EEH:HER7:UBEW:33KA:MZTD:IVV7:GRQH:XFZR:WSIV:EWA2:RZIK
Debug mode (server): true
File Descriptors: 11
Goroutines: 17
System Time: 2015-11-23T15:58:59.917311419Z
EventsListeners: 0
Init SHA1:
Init Path: /usr/local/bin/docker
Docker Root Dir: /mnt/sda1/var/lib/docker
Labels:
provider=virtualbox
$ uname -a
Darwin xxx 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
NOTE: This issue replaces https://github.com/docker/docker/issues/18168 since the definition of a tag is contained in this repo at https://github.com/docker/distribution/blob/master/reference/regexp.go#L25
About this issue
- Original URL
- State: open
- Created 9 years ago
- Reactions: 86
- Comments: 31 (2 by maintainers)
Commits related to this issue
- Add support for semver tags + tests - Addresses issue #1201 — committed to samsalisbury/distribution by samsalisbury 9 years ago
- Add support for semver tags + tests - Addresses issue #1201 Signed-off-by: Sam Salisbury <samsalisbury@gmail.com> — committed to samsalisbury/distribution by samsalisbury 9 years ago
Changing this has nothing to do with Docker’s versioning scheme. The request is to simply expand the reference grammar for tags as defined here https://godoc.org/github.com/docker/distribution/reference to fully support the grammar for semver defined here http://semver.org/. The difference today is related to supporting
+as a valid character in the tag and before we can accept such a change the impact must be fully enumerated. We are awaiting someone to take on the work of fully enumerating the impact.https://github.com/docker/distribution/blob/master/reference/regexp.go#L37 My kingdom for a one character change: TagRegexp = match(
[\w][\w.-]{0,127}) TagRegexp = match([\w][\w.+-]{0,127})Guessing the reason for this bug not being fixed is docker repo implementations. A a little warning to them and a date by which the update will go out would get the ball moving.
… just read stevvooe’s comments, makes sense.
+100
However, didn’t you made the assumption in #1202 that the
+part is meant to be ignored by docker when it could only be ignored by systems comparing if a version is before or after another version?Let me explain myself better: docker will not be a semver only system as per your comment
Docker will never enforce this. There is no need for docker to treat differently a semver version just like other doesn’t threat it differently either, its just a label.If we can agree on this, then its kinda-sorta just changing the regex and making sure its properly covered by tests.
i.e: if we think about
correct; similar to
gitallowing you to tag a commit, git itself does not put any meaning to the tag itself (v1.0.0could be “semver” if you say it is, but just as well meanv=vavavoom,1=Monday,0=temperature in celsius,0=mouse-distance in inches)There’s a finite amount of engineering time, so choices always have to be made; https://github.com/docker/distribution/issues/1201#issuecomment-372854179 links to some of the things that are needed, and (as anything open source), community participation is definitely welcome. Apart from the things listed there, things needed are;
It looks that in #1202 it was pretty much agreed that docker just sees this as a string / label and nothing more - it doesn’t need to compare version / determine precedence on this in any way… so it shouldn’t overly care about the string used.
Organisations produce many types of artifacts - of which docker images are now one kind. Many other kinds of artifacts (look at the major package managers) support semantic version numbers. Therefore it’s natural that organisations that produce these kinds, and use SemVer, want to also use SemVer when producing docker images. Due to how widely SemVer is used, I am surprised this hasn’t been addressed to date - but obviously other things on the roadmap for docker have been more pressing 😃 Still this would be a valuable thing to accomodate imho.
More like ignored by maintainers… someone could probably easily make a PR to remove + from the validation function. It’s unnecessarily restrictive. There hasn’t been any explaination of why.
Please keep it civil. The maintainers have made their position abundantly clear in https://github.com/docker/distribution/pull/1202#issuecomment-160761964. There is also https://github.com/docker/distribution/issues/1201#issuecomment-285142501, which is a few comments above. There is also https://github.com/moby/moby/issues/16304. It’s quite clear that there is risk here that needs to be understood before just changing a regexp.
You’re more than welcome to take on this work.
Any update on this issue? Not being able to tag my docker image with information that I deem relevant, whether that is a
+in semver, or other characters if I would like to use them, is very limiting.Only being able to use alpha-numeric characters and dashes seems unnecessarily restrictive.
It would be great if someone could “enumerate the impact” of this change as a matter of priority?
@matthewwiesen Seems like that is for Docker itself. If, as part of an organization, we use semver or similar versioning for our own images the idea would be that Docker tags should ideally support it.