Skip to content

doc/spec: namespaces and discovery - #179

Closed
dmcgowan wants to merge 2 commits into
distribution:masterfrom
dmcgowan:namespace-proposal
Closed

dmcgowan wants to merge 2 commits into
distribution:masterfrom
dmcgowan:namespace-proposal

Conversation

@dmcgowan

Copy link
Copy Markdown
Collaborator

Includes description of namespace, discovery process, registry metadata, and trust models.

Connects to #188.

Comment thread doc/spec/namespace.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the api.md file but I don't know what a "docker-scope" means here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"docker-scope" is basically the namespace prefix. A preamble should be added to the introduction outlining this concept.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of the scope is to inform a discovery client as to what namespaces this metadata may apply to. Caching may be undesirable but the idea here is to leave that up to client. In this case the same metadata should be returned for any image named "registry.example.com/*".

@stevvooe stevvooe changed the title Proposal: Namespaces and discovery doc/spec: namespaces and discovery Feb 18, 2015
Comment thread doc/spec/namespace.md Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble with doing this is that unlike HTTPS you can't trust anything coming over DNS. So, you don't know if the data you are getting has been modified via man-in-the-middle. This is one of the reasons we keep going back and forth on that feature on the App Container spec: appc/spec#3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This portion of the specification needs a clarification in that these are examples of possible discovery protocols, rather than the one-true-discovery-protocol. Yes, you can't trust anything coming over DNS, but there may be a scheme that could use signed TXT entries or could leverage DNSSEC. A pluggable discovery system should not prevent this, even if it could be terribly insecure.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for linking to that conversation, agreed the same problems apply here. If we cannot support DNS securely, it will not be supported. It is intentionally missing details now so we can discuss how this may support securely.

@stevvooe

Copy link
Copy Markdown
Collaborator

@stevvooe

Copy link
Copy Markdown
Collaborator

cc @bfirsh

@dmcgowan
dmcgowan force-pushed the namespace-proposal branch 3 times, most recently from 14762c1 to 984a512 Compare February 25, 2015 01:10
Comment thread doc/spec/namespace.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If scopes are intended to be a guarantee on all namespaces matching the prefix I'd want to tighten up the language; "will apply" vs "may apply". If scopes aren't a guarantee then they seem to lose a lot of value.

@dmcgowan

Copy link
Copy Markdown
Collaborator Author

Defining a grammar is the best combination of legibility and strong definition. The grammar defined may be useful for the discovery protocol, however it doesn't change the definition of the canonical name. A discovery protocol must support name definition.

@stevvooe you are right we should add port to the definition since that is what is currently supported and SRV records should not be required.

Includes description of namespace, discovery process, registry metadata, and trust models.

Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
@dmcgowan

Copy link
Copy Markdown
Collaborator Author

Added ports to hostname definition. @stevvooe if the grammar definition looks too much like a URI, what would be a better way to name the components. DNS name + path does sound like a URL. Essentially we have a domain and a domain specific repository name as part of the canonical name, perhaps refer to it as domain + repository name? Other suggestion was adding canonicalization rules which would specify when a repository domain is omitted, the default domain must be used.

@stevvooe

Copy link
Copy Markdown
Collaborator

@dmcgowan I was thinking something along these lines for the grammar (sorry, this is more peggish):

alpha-numeric := /[a-z0-9]+/
separator := /[._-]/
component := alpha-numeric  [component-separator alpha-numeric]*
namespace := component ['/' component]*

Then limit the namespace production to 255 characters or less (not sure how to represent that in the grammar. This is effectively what we have elsewhere.

Edit: I added this to the validation documentation for names in #212.

Comment thread doc/spec/namespace.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The total length of a name is 255..." should be "The maximum length of a name is 255..."? This may also be worth clarifying with an example:

The canonical repository name `example.com/foo/bar` is 19 bytes long. The host
name `example.com` is 11 bytes long, leaving up to 244 bytes available for the
path component of the name, including a leading `/` path separator character.

@endophage

Copy link
Copy Markdown

Just some thoughts I had over the weekend:

Taking the example "example.com/foo/bar", "example.com" really identifies the registry, while "/foo/bar" identifies the repository. "example.com" might be a mirror, or it might be a unique repository. Would it make sense to divide up the concepts such that a user can add a registry identifier locally, and make it responsible for some repositories?

In that scenario, the problem of having a global namespace is reduced to a problem of making a user responsible for managing the registries they use, and what repositories are owned by those registries. There is no longer an issue if "foobar.com/foo/bar" also publishes a conflicting "/foo/bar" repository because the user must add "foobar.com" and identify it as the owner of "/foo/bar"

This would also fold into package signing well. For any registry the user wishes to add, the user must either identify it as insecure, or add the cert for that registry.

I'd envision a command something like:

docker add-registry example example.com --namespaces /foo/bar,/foo/baz
docker pull example/foo/bar/thingy:latest

@stevvooe

stevvooe commented Mar 2, 2015

Copy link
Copy Markdown
Collaborator

@endophage We need to be a little careful here: the DNS name at the start of a namespace is not the location of the registry. The DNS name at the start of namespace corresponds to the scope of the image names. That DNS name may be used to discover the registry, in turn. This is a key distinction to avoid confusing UX, such the current state of docker cli or the suggested command.

However, following from your example, I do see the idea of being able to configure remotes to be a good one. For example, something similar to git might work really well:

docker remote add example.com registry.example.com

This would be the CLI portion of the configurable discovery system. Want to know which remotes a docker daemon would pull from:

$ docker remote -v
docker.com  https://registry-1.docker.com/ (pull)
example.com https://localhost:5000/

Let's play with this idea.

Comment thread doc/spec/namespace.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a table enumerating the resulting components of discovery. It includes the following:

  • registry
  • index (search)
  • trust system
  • ?

This should be an explicit part of this specification.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable. Although the word "registry" seems ambiguous in this use case. Is the result of discovery a registry instance (as in the Go interface) or a registry configuration. The difference being whether we want to consider each endpoint itself a registry, and the resulting registry may be a collection of registries or have the registry contain a configuration with api server endpoints.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmcgowan Understood. Let's find a word more specific than "endpoint" and less abstract than "registry". Perhaps, we may need to shuffle some nomenclature to make this work.

@endophage

Copy link
Copy Markdown

It seems like currently we're making the DNS name do double duty, both as a unique global identifier and the location, at least that's what I understand so far. I don't know that it has been explicitly stated anywhere, but it seems like that would be the result of a concrete implementation. If there already is some idea on separating the namespace from the location information, we should call it out more explicitly.

Being able to configure remotes I see as a way to separate the concerns of location and namespace. I'm not picky on the syntax, docker remote add ... works great too 👍

Additionally, I see a benefit of separating the location information out in allowing us to specify a scheme to more easily support non-http registries. If our registry.example.com location supported ftp and torrents, a user might run (of course we could also have scheme take multiple arguments):

docker remote add example.com registry.example.com --protocol=ftp
docker remote add example.com registry.example.com --protocol=torrent

@stevvooe

stevvooe commented Mar 2, 2015

Copy link
Copy Markdown
Collaborator

@dmcgowan Let's add a canonicalization section to this proposal. We need to answer the following questions (with straw man answers):

  • What does the name "ubuntu" become when mapped to a namespace?

    The simple name "ubuntu" will be converted to "dockerlibrary.org/library/ubuntu".

  • What do two-level names ("username"/"repository") map to?

    Names like "stevvooe/test" map to "hub.docker.com/stevvooe/test" to support backward compatibility with the hub.

These canonicalizations would not be permanent but really would provide a plan to migrate from simple names to long names.

@endophage

Copy link
Copy Markdown

Scratch my suggestions. I hadn't fully internalized the discovery portion of this proposal.

@wyaeld

wyaeld commented Mar 6, 2015

Copy link
Copy Markdown

@stevvooe Can you walk us through the approach where an organisation has multiple registries, and wants to move a deliverable through them? Currently in Docker the coupling of name and transport/registry makes this very difficult.

$ docker remote -v
docker.com  https://registry-1.docker.com/ (pull)
trusted https://registry.mycompany.org:5000/
untrusted https://developers.mycompany.org:5000/

We often have these layers. Developers can push to untrusted, Production systems or end subscribers can only fetch from trusted. Someone in the middle has to promote one way or another.

So my teams want to build an image mycompany/myapp:1.0 and push it to untrusted.
People pull it from there, test it, and when everyone is happy and signed off, it gets pushed to trusted.

Can I actually do that under this namespace proposal, without having to add what feels like superflous tags to the front of everything (ignoring the promotion step, that logic is obviously out of scope)

@stevvooe

stevvooe commented Mar 6, 2015

Copy link
Copy Markdown
Collaborator

@wyaeld We are separating names and locations. This is the entire point of namespaces and discovery. It is also the goal of the new distribution system. The confusion here may be that they look like urls, which is a convenience. The name is designed to provide a clue, but it doesn't affix the ultimate location. This makes simple cases easy and hard cases possible.

We may be able to better explain the concept in terms of the straw man cli syntax. For this example, let's say we have the roles of "developers", "promoters" and "production". The "developers" can pull from "production" and pull/push from "untrusted" as a policy.

The "developers" docker instance would be configured as follows:

$ docker remote -v
docker.com  https://registry-1.docker.com/ (pull)
mycompany https://developers.mycompany.org:5000/ (push/pull)

This would allow the developers to push and pull to namespace mycompany as much as they like. This configuration never leads to them pushing to anywhere they shouldn't. The user doesn't even need to know about the other registries. It can also be tested and verified by others with the same configuration.

The "promoters" docker instances would be configured to pull from "developers" and push to the production registry:

$ docker remote -v
docker.com  https://registry-1.docker.com/ (pull)
mycompany https://developers.mycompany.org:5000/ (pull)
mycompany https://registry.mycompany.org:5000/ (push)

This would allow the instances to pull from the "developers" created image, run some tests, and maybe run as a staging instance. When it's deemed ready, they can then push the image to the other configured repository.

This example is roughly the model of git with the ability to manage multiple repositories by namespace. In the same vein of git, to support various distribution models, breaking out of this model should be possible:

$ docker push --registry https://oddplace.mycompany.org:5000/ mycompany/myapp:1.0

The main difference is that the name of the remote can be a part of the "branch" (or image name).

While this thought exercise does work, using the location (registry) to manage promotion state may not the best idea. This is really what tags (at least the future of them) are for. The registry (the new one) is really designed as a system to move data around. The state of the data should be the responsibility of tags and the trust system. It provides the right model and much better guarantees.

I hope this clarifies things.

@wyaeld

wyaeld commented Mar 6, 2015

Copy link
Copy Markdown

Thanks, great clarification, and addresses what we are after.

tags alone aren't sufficient for the use-cases of the top-end of security conscious customers, they sometimes want it to be impossible to move untrusted/unaudited artifacts into secure environments.

Promotion state will typically be managed by an external system which is very workflowish, but handles automatically pulling from untrusted and pushing to trusted at the right time. That way, even if you had root access to a production system, you can't pull an artifact that has never been approved for distribution into the trusted registry.

would this work under your model? (shorthand form similar to git remotes)

docker remote add oddplace oddplace.mycompany.org:5000
docker push oddplace mycompany/myapp:1.0

Signed-off-by: Derek McGowan <[email protected]> (github: dmcgowan)
@endophage

Copy link
Copy Markdown

I think we should settle on and codify in this proposal, the git-inspired syntax of

docker remote add <my local name> <url to discovery endpoint>

We should also aim for more consistency than Git and standardize that the local registry name is always separated by a space from a repository:tag. In some cases (fetching/pulling) git uses a / and in others (pushing) it uses a space and it's ridiculously frustrating when you're first learning git and keep using the wrong syntax for a given command.

Allowing a user to manage their local namespace this way makes the problem of a globally unique namespace a moot point, because everyone's view of the world will be different and it's up to them to decide what they want it to look like. If we can equate it to the Git model, we can leverage existing user knowledge to make it simple to learn.

@stevvooe

Copy link
Copy Markdown
Collaborator

@dmcgowan

We may want to add something codifying these particular goals:

  1. Images have a single, global name.
  2. Image names are separate from their transport and location.
  3. An image name can be verified with strong cryptography.

These kind of define the namespace problem and the handoff point to the trust system.

@titanous

Copy link
Copy Markdown

@stevvooe

Images have a single, global name.

This is something that can't be enforced (and why should it be?). An image can have zero or more names, there's no way to limit it to one unless the name is the cryptographic digest of the image.

An image name can be verified with strong cryptography.

What does this mean?

@stevvooe

Copy link
Copy Markdown
Collaborator

@titanous Sorry if these came out a little silly. These goals are more high-level than anything. They are meant to frame the concept of namespaces and the problems this proposal is meant to solve. These are not rules.

Images have a single, global name.

This is something that can't be enforced (and why should it be?). An image can have zero or more names, there's no way to limit it to one unless the name is the cryptographic digest of the image.

Just because it's unenforceable doesn't mean it can't be stated as a goal. No, it cannot be enforced under varying definitions of global. Meeting that goal might be to restrict the definition of "global" to a trust domain.

An image name can be verified with strong cryptography.

What does this mean?

Simply that the target of a name can be verified. This is almost tautological but the idea is that the name is both human-readable and verifiable (perhaps, that should be a goal...). There are names that are human-readable but not cryptographically verifiable. A possible response to such a goal might include casing rules or restrict the character set used.

@wyaeld

wyaeld commented Mar 11, 2015

Copy link
Copy Markdown

@stevvooe what problem is the single name concept try to solve? A single SHA in git is verifiable, but might be named HEAD, origin/master, myapp:1.0 etc all at the same time. I feel like names are transient. The resolution of a name is determined by what git providers (or registries in this case) I choose to include in my worldview.

Comment thread doc/spec/namespace.md

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you're more interested in a "domain name" than a "host name". Cloud Foo Inc. would probably publish their images with namespace cloudfoo.io, which is not the name of a host. It is merely the name of a domain. I suggest using the phrase "domain name" instead of "DNS host name". If you want to be more specific, you could reference RFC 1034.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading further, I see that you also want to include a port, which is not part of a domain or host name. :) Perhaps "domain name and port" or "fully qualified domain name and port" would be more accurate?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmcgowan We may want to reconsider the addition of ports, in light of some of the recent discussion on discovery.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if the 'default' registry deployment was targeted at port 443, with a cert, and reverse proxy (if required). Then just give instructions to cut out those parts if people don't want them.

I doubt anyone actually wants to run their registry publicly on http/5000. Its done because for a long time, there wasn't a documented solution to do it properly.

Secure by default is a thing

@stevvooe

Copy link
Copy Markdown
Collaborator

@wyaeld Everything your saying is completely accurate. We are already bringing git-like hashes to refer to images, with moby/moby#11109. Now, we need to balance that approach with a sane naming scheme, hence the goal.

For this goal, however, I am not sure git is the right analogy. Images are not branches. A more apt analogy is the domain name system. The physical location of "docker.com" or "github.com" may change, via DNS, but one can confirm that the update is accurate via a certificate.

Remember, these are just goals and not binding technical requirements. They frame the discussion and provide a base for the actual requirements.

@titanous

Copy link
Copy Markdown

@vladimir-v-diaz As long as the user/repo delegation is optional, I think the non-Docker Hub TUF use case can be exactly the same. The client will have an entry in its trust store mapping a repo URL to root key(s), I don't think there's any reason to special case it.

@vladimir-v-diaz

Copy link
Copy Markdown

@titanous @endophage @JustinCappos
Having an entry in a trust store mapping a repo URL to root key(s) also works.

Is there a connection between non-Docker Hub repositories and Docker Hub? If so, does Docker Hub distribute the root.json metadata belonging to these exernally-managed repositories? If there isn't, how do non-Docker repositories distribute their root keys?

I'm only wondering how the initial trust is established for the Root keys of non-Docker repositories.

@dmcgowan

Copy link
Copy Markdown
Collaborator Author

Cutting new PR to split trust TUF conversation from namespace/discovery

Trust conversation should move to #287 or the resulting spec

Namespace/discovery conversation should continue on the new PR #303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants