-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
WIP: Docker networking support #1676
Conversation
Does links going to be dropped from Docker itself like you did in docs? Never heard about that. Also you do not currently mention how to provide aliases like Also
Is quite a big issue, there should be a way to differentiate them, adding suffixes would allow, for instance, load balancer to discover all web servers automatically to do its job. |
Instead of defining your services at the top-level in `docker-compose.yml`, place them under a `services` key, and define networks under a top-level `networks` key. | ||
|
||
Here's how you would set up a 2-network, 3-container app where the `nginx` and `db` services cannot discover or communicate with each other directly: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section should focus on providing the flexibility to run multiple apps in a single network. For example, docker compose up -d --net=<network>
(and any equivalents of that which might feature directly within the Compose file if we want to support specifying networks in the Compose file).
I don't think support for containers connecting to multiple networks in 1.8 timeframe is realistic. I think there are broad range of libnetwork, network driver and service discovery interaction and implementation issues that need to be resolved to make that work sensibly. I suggest restricting each container to a single network for 1.8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Everything works neatly in the example given, but it's easy to construct a scenario which is not so clear; for instance if there are containers published as foo
in both networks, what answer should web
get if it asks for foo
? (You could answer "just don't do that" I suppose, but it would be better to come up with a model that avoids such an ambiguity).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm just going to remove this section for now.
|
||
# Networking in Compose | ||
|
||
By default, Compose sets up a single default [network](http://TODO/docker-networking-docs) for your app. Each container for a service joins the default network and is discoverable via DNS under the service's name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to say "via the system resolver" or similar here, instead of DNS specifically. Some solutions (e.g., the incumbent) will use /etc/hosts
as a mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I've reworded this sentence.
@aanand @bfirsh If this is experimental in the next release, do y'all want to create an experimental directory to hold the documentation? Then we can point to this directory from release notes and blogs. The idea is only released features go in docs.docker.com and experimental feature documentation goes into an experimental directory. That way, "risky" features aren't presented to users who might miss the experimental aspect in the official docs. |
Just an update: I've started on an implementation of the networking API in docker-py: docker/docker-py#729 Following conversation with @mavenugo, we're considering renaming "networks" to "scopes" (at the Docker Engine and API level), and removing all talk of networking, since that's not the real developer-level concern (rather, it's service discovery). I'm going to push an update to the docs to that effect. |
@aanand Can you give me a definition of scope in this context? I was looking through the PR and trying to replace "network" with "scope" as used...it wasn't coming out clean. Scope is a synonym for range. And depending on how you use it in context could cause confusion. |
@moxiegirl Sure. It's similar to how programming languages define "scope", as in "a context in which a particular name means a particular thing". I'll ignore Compose for a moment and demonstrate using hypothetical Docker client syntax. Suppose I have two applications. I create a scope for each, called say
In each app's scope, there is a set of services, each with a name that's unique within that scope. A container in that app's scope can publish as a backend for a particular service.
Within the
Within the
|
@aanand So, I'm expecting the work Also, I'm still waiting to hear if this is "experimental" or going out finished...whatcha thinking? |
@moxiegirl thats correct. it will appear in networking.md shortly. Also, the word the experimental networking features will be part of 1.9 proper release & it is appropriate to have that assumption in compose. |
@aanand, @mavenugo: Can you confirm that the |
@lxpollitt thats correct. |
Alex, yes that is correct. They are still networks, nothing has changed. We On Wed, Aug 26, 2015 at 2:25 PM, moxiegirl [email protected] wrote:
|
@shykes Do you have any feel for whether it is general developers (i.e. users of Docker) or network people (i.e. libnetwork plug-in implementors) getting confused? Or is it just people in general? I have a networking focus in my interests here, but I really don't mind what it is called, so long as its definition is clear and I don't foresee implementation challenges. Given that Where it gets trickier from for service discover and networking implementations is around whether a single container can exist in / be connected to multiple scopes and what the expected behavior is in those cases. I don't know what the latest thinking on that is, but that's probably a discussion for another day. |
For me personally it is tricky because "scope" is not directly associated with network alone - Docker have FS layer with its own drivers, for instance. Why not just call it "network", no one will be confused about what it actually does. |
Attention: this has been updated with the docs for the final planned functionality for Docker 1.9 / Compose 1.5. Please take a second look. |
Nice! My only concern is that removing links is a huge change for users. It might be worth sprinkling around some helpful notes. "links are no longer used in Compose 1.5... check out the networking docs to read about the future" Also - presumably we will force users to update to Docker 1.9 in Compose 1.5? If a user doesn't want to upgrade to 1.9, we should make sure users can still find the Compose 1.4 docs with "links", etc. |
How does a compose project use any network driver besides the default driver? Is it possible for a compose project to join an existing network? |
I'm not fully comfortable with this proposal. First off, I'm glad to see the docker networking UX finally land in 1.9, but I think the jury's still out on how users will use networks. Here's my observations thus far... Users really want cross host networking. That has been said loud and clear. Beyond that simple request I don't have a clear picture of why users want networks as a first class object from an application perspective. I work with a good amount of users and I rarely get requests where people want VPC-like or OpenStack Neutron like functionality in Docker from an application perspective. What I do get is a lot of requests where people want to plug docker into an existing network fabric. OVS, VLANs, or something crazy. They have a network managed by another team and they just need the Docker containers to play nice with the existing networking model. So you can see that this is more of an administrative function and not a user/developer function. Once Docker 1.9 is out I will be working with a lot of users to address these one off networking requirements. I would much rather see compose hold off on using networks as a core part of the functionality. I think compose should support For example, I am working with some one now that must plug Docker into OVS in an extremely custom way. The way in which they are doing this, having a single Docker network for their custom set up makes sense, and then use that network as the default. They have no requirement to create multiple "networks" in Docker. Now if I want to deploy two compose templates and both have a container named "foo" the only way I can do that after this proposed change would be to create two networks. But... in the scenario I described they can't create two networks. The only way I can support two network with this OVS approach is if I write a driver that creates "pseudo" networks. Now this just gets really odd. What compose really needs is service discovery namespacing, not networks. Again, I think compose should just hold off a bit. Lets see how users used Docker networks first. |
I think this proposal supports the situation you describe with That said, I think it would be good to allow users to customize the default network (if they don't want it to be the project name), and to allow them to completely disable creating a default network. I don't know if those features will be available for the initial release. |
A small update: following discussion with @mavenugo and @dave-tucker, we're going to use How it'll work is: if you've set a This means that joining under multiple names, or no names at all, will not be supported for v1 - we'll be holding off on those until there's an actual service discovery API. I've updated the doc: |
@aanand How does scaling work now. From what I understand you are saying either service name from compose or the hostname will be set to the container name (ie |
@ibuildthecloud The container name isn't used anywhere. If you've set web:
hostname: mywebservice then Compose will send If you haven't set a In both cases, each container will join the network under that name. If you create multiple containers, they'll join under the same name. If you look up the hostname This is basically the same behaviour that scaling gives you today. It's not very useful, but it's a start - we need a proper load-balancing solution to make it viable. |
@aanand is there a way to specify container scaling in the yml, so that |
52b8446
to
033d96e
Compare
The link to the git commit in the requirements isn't working, I think that's why the tests are failing. The code itself LGTM. |
b363767
to
376a8dd
Compare
This is now ready to merge, other than the fact that it still depends on docker/docker-py#729 and moby/moby#16645. It skips the networking-related tests unless running against a 1.9.x daemon - once there's a 1.9.0 RC out, thanks to @dnephin's work in #2069 they should automatically start running. |
I will add this to bash completion once it is merged. |
Signed-off-by: Aanand Prasad <[email protected]>
Merging as part of #2191 |
This is starting out as a docs-only PR, meant to get early feedback on the direction of Docker's networking support, from the viewpoint of Compose. It's scoped to what we plan to implement in the first stable release.
Your comments are welcomed.
Replaces #1346.
ping @dave-tucker @bfirsh @shykes @mavenugo @lxpollitt @monadic