New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid registry name/repo name not parsed by regexp in 1.10 #1433

Closed
gaborho opened this Issue Feb 5, 2016 · 6 comments

Comments

Projects
None yet
5 participants
@gaborho
Copy link

gaborho commented Feb 5, 2016

In 1.10 it seems regexp validator got broken, and cannot parse correctly a valid registry/repo name.

Steps to reproduce:

  1. Issue a pull command from the following registry with 1.10

docker pull registryELB-999514288.eu-west-1.elb.amazonaws.com:5000/ghorvath/test-haproxy:latest

  1. Following error is displayed:

Error parsing reference: "registryELB-999514288.eu-west-1.elb.amazonaws.com:5000/ghorvath/test-haproxy:latest" is not a valid repository/tag

Expected results: image got pulled.

Same command works with 1.9.1. Registry and repo exists.

Docker daemon was not contacted during issuing the command.

Regexp relevant code snippet is here:

// alphaNumericRegexp defines the alpha numeric atom, typically a
// component of names. This only allows lower case characters and digits.
alphaNumericRegexp = match(`[a-z0-9]+`)
// separatorRegexp defines the separators allowed to be embedded in name
// components. This allow one period, one or two underscore and multiple
// dashes.
separatorRegexp = match(`(?:[._]|__|[-]*)`)
// nameComponentRegexp restricts registry path component names to start
// with at least one letter or number, with following parts able to be
// separated by one period, one or two underscore and multiple dashes.
nameComponentRegexp = expression(
alphaNumericRegexp,
optional(repeated(separatorRegexp, alphaNumericRegexp)))
// hostnameComponentRegexp restricts the registry hostname component of a
// repository name to start with a component as defined by hostnameRegexp
// and followed by an optional port.
hostnameComponentRegexp = match(`(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])`)
// hostnameRegexp defines the structure of potential hostname components
// that may be part of image names. This is purposely a subset of what is
// allowed by DNS to ensure backwards compatibility with Docker image
// names.
hostnameRegexp = expression(
hostnameComponentRegexp,
optional(repeated(literal(`.`), hostnameComponentRegexp)),
optional(literal(`:`), match(`[0-9]+`)))
// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
TagRegexp = match(`[\w][\w.-]{0,127}`)
// anchoredTagRegexp matches valid tag names, anchored at the start and
// end of the matched string.
anchoredTagRegexp = anchored(TagRegexp)
// DigestRegexp matches valid digests.
DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`)
// anchoredDigestRegexp matches valid digests, anchored at the start and
// end of the matched string.
anchoredDigestRegexp = anchored(DigestRegexp)
// NameRegexp is the format for the name component of references. The
// regexp has capturing groups for the hostname and name part omitting
// the seperating forward slash from either.
NameRegexp = expression(
optional(hostnameRegexp, literal(`/`)),
nameComponentRegexp,
optional(repeated(literal(`/`), nameComponentRegexp)))
// anchoredNameRegexp is used to parse a name value, capturing the
// hostname and trailing components.
anchoredNameRegexp = anchored(
optional(capture(hostnameRegexp), literal(`/`)),
capture(nameComponentRegexp,
optional(repeated(literal(`/`), nameComponentRegexp))))
// ReferenceRegexp is the full supported format of a reference. The regexp
// is anchored and has capturing groups for name, tag, and digest
// components.
ReferenceRegexp = anchored(capture(NameRegexp),
optional(literal(":"), capture(TagRegexp)),
optional(literal("@"), capture(DigestRegexp)))

Environment:

root@gabor-vbox:~# docker version
Client:
 Version:      1.10.0
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   590d5108
 Built:        Thu Feb  4 18:41:30 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.0
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   590d5108
 Built:        Thu Feb  4 18:41:30 2016
 OS/Arch:      linux/amd64


root@gabor-vbox:~# docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 3
Server Version: 1.10.0
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 5
 Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Plugins: 
 Volume: local
 Network: bridge null host
Kernel Version: 4.2.0-16-generic
Operating System: Ubuntu 15.10
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.954 GiB
Name: gabor-vbox
ID: TDRH:X2C6:7JGJ:BDSQ:BBIL:6JUH:ZOZ7:DKQW:R33G:SGWF:S4ML:ZKRL
Http Proxy: http://xxx:xxx@xxx
WARNING: No swap limit support

Kindly ask you to verify, confirm and correct the issue.

@stevvooe

This comment has been minimized.

Copy link
Contributor

stevvooe commented Feb 5, 2016

@ATLD Names have always been case insensitive (registryelb is the same as registryELB). 1.10 had some changes to ensure that naming validation logic is more consistent.

Arguably, the case should be flattened before being parsed into a reference. As a workaround, just use registryelb-999514288.eu-west-1.elb.amazonaws.com:5000/ghorvath/test-haproxy:latest. Probably should add this to reference.Parse.

@gaborho

This comment has been minimized.

Copy link

gaborho commented Feb 5, 2016

Thank you @stevvooe, it works with your suggested workaround.

@aaronlehmann

This comment has been minimized.

Copy link
Contributor

aaronlehmann commented Feb 5, 2016

Confirmed that there's a difference in behavior between 1.9 and 1.10. 1.9 disallowed uppercase letters in remote repository names, but 1.10 also disallows them in hostnames.

With 1.9:

# docker tag registry:2.2.1 OldRegistry:2.2.1
repository name component must match "[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*"
# docker tag registry:2.2.1 SomeHostname:8080/registry:2.2.1
[success]

With 1.10:

# docker tag wordpress WordpressImage
Error parsing reference: "WordpressImage" is not a valid repository/tag
# docker tag wordpress SomeHostname:8080/wordpress     
Error parsing reference: "SomeHostname:8080/wordpress" is not a valid repository/tag

This probably needs to be fixed to prevent stranding existing images that have uppercase letters in hostnames.

aaronlehmann added a commit to aaronlehmann/distribution that referenced this issue Feb 6, 2016

Allow uppercase characters in hostnames
This allows hostnames to contain uppercase characters, matching behavior
in Docker versions before 1.10. It does not attempt to canonicalize
hostnames into a lowercase format before parsing, since this could lead
to corner cases (for example, making Hostname.Domain.Com/ref ambiguous
on a daemon which contains references for both hostname.domain.com/ref
and Hostname.Domain.Com/ref).

Fixes: docker#1433

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

aaronlehmann added a commit to aaronlehmann/distribution that referenced this issue Feb 6, 2016

Allow uppercase characters in hostnames
This allows hostnames to contain uppercase characters, matching behavior
in Docker versions before 1.10. It does not attempt to canonicalize
hostnames into a lowercase format before parsing, since this could lead
to corner cases (for example, making Hostname.Domain.Com/ref ambiguous
on a daemon which contains references for both hostname.domain.com/ref
and Hostname.Domain.Com/ref).

Fixes: docker#1433

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

aaronlehmann added a commit that referenced this issue Feb 8, 2016

Allow uppercase characters in hostnames
This allows hostnames to contain uppercase characters, matching behavior
in Docker versions before 1.10. It does not attempt to canonicalize
hostnames into a lowercase format before parsing, since this could lead
to corner cases (for example, making Hostname.Domain.Com/ref ambiguous
on a daemon which contains references for both hostname.domain.com/ref
and Hostname.Domain.Com/ref).

Fixes: #1433

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

RichardScothern added a commit that referenced this issue Feb 23, 2016

Allow uppercase characters in hostnames
This allows hostnames to contain uppercase characters, matching behavior
in Docker versions before 1.10. It does not attempt to canonicalize
hostnames into a lowercase format before parsing, since this could lead
to corner cases (for example, making Hostname.Domain.Com/ref ambiguous
on a daemon which contains references for both hostname.domain.com/ref
and Hostname.Domain.Com/ref).

Fixes: #1433

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>

naamunds added a commit to dotnet/dotnet-docker that referenced this issue Mar 18, 2016

Fix example tag name in README
Tag names are case-insensitive in Docker, and Docker 1.10 introduced
validation logic that causes `docker build` to fail if the specified tag
contains uppercase characters, as stated in docker/distribution#1433.

It appears that Docker container names are case-sensitive, but the
default container names are all-lowercase with underscores, and I think
it looks better to use the same naming convention for tag names and
container names in the `docker run` example command.

I chose hyphens over underscores because our tags in this repo use
hyphens (e.g. 0.0.1-alpha-onbuild), but underscores would be fine too.
@graywh

This comment has been minimized.

Copy link

graywh commented Jun 29, 2016

It looks like #1434 fixed this issue for hostnames, but uppercase is still rejected on container names on 1.11.2.

@aaronlehmann

This comment has been minimized.

Copy link
Contributor

aaronlehmann commented Jun 29, 2016

Yes, rejecting uppercase characters in remote image names (the part after the hostname) is done intentionally for preserving backward compatibility. Previous versions of Docker don't allow uppercase characters here, so if we started allowing them, that would result in images that older versions of Docker can't pull.

@jedwards1211

This comment has been minimized.

Copy link

jedwards1211 commented Sep 15, 2016

This is one of those cases where a simple "no uppercase characters allowed" error message would have saved us all time

dalsh added a commit to dalsh/distribution that referenced this issue Jan 13, 2017

Allow uppercase characters in hostnames
This allows hostnames to contain uppercase characters, matching behavior
in Docker versions before 1.10. It does not attempt to canonicalize
hostnames into a lowercase format before parsing, since this could lead
to corner cases (for example, making Hostname.Domain.Com/ref ambiguous
on a daemon which contains references for both hostname.domain.com/ref
and Hostname.Domain.Com/ref).

Fixes: docker#1433

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment