-
Notifications
You must be signed in to change notification settings - Fork 879
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
Support for container aliases when joining a network #737
Comments
And multiple names |
+1 - the container should be able to identify itself with more than just its name for purposes of network topology. |
With links it was really useful to be able to set the alias to something like mynet.example.com when trying to replicate non-docker environments for local test purposes. Supplying an alias on network connect (or some other way) would be really useful. |
+1 This will be very useful when using docker containers on a mesos cluster since the container name is assigned by the mesos agent (slave). |
This is pretty much a mandatory need when using Docker Compose, given that the preferred use of Compose is to allow it to set container names when they are spun up. So consider this a hearty +1. |
thanks everyone for the comments. @dnephin @cpuguy83 @delfuego when we use links, the aliasing of the container name is specified at the time of linking and not during the time of container (that is being linked and aliased here) create. This provides a nice functionality of the child container calling the parent anything it wants as defined in the application that is running inside container. But by providing an alias for a container when it is connected to network, we are essentially providing the alias at the container connect time. That means the child container that is linked (via the network & SD) to the parent cannot be made 1-1. User would have to start changing the expectations on the 1-1 name alias between a pair of containers. Instead it will be a 1-N relationship within the network. i.e., a container can be aliased, but that alias will be available for all other containers in that network. Is that acceptable ? Also, how dynamic and generic we see this alias feature to be ? Should this be a generic engine feature on a container to have multiple names (or) specific to networking for the purpose of linking containers using multiple names ? How dynamic should we make this and how would the UX look like ? Any ideas ? |
@mavenugo Yes, I agree it would be difficult to have an alias apply like it does with links today. |
The most important thing for compose is that a container is accessible by names docker-compose defines. That way the default discovery naming is backwards compatible with the default link names (servicename, and servicename_num). An alias being available to every container doesn't seem like a problem for most uses. There may be some configurations that need to change, but as long as we can provide arbitrary aliases for a container, it should be workable. We create a network for each compose project, so the N is just the services defined within a single Compose file.
I don't think we want a container to have multiple names. I think it's specific to networking (links support multiple aliases with a single container name).
I think setting the aliases at connect time sounds appropriate (I agree with the example @cpuguy83 provided). From the cli: From compose we'd add a second for aliases to the compose file, so that users could set a custom name. @aanand had a PR with the docs for this a while back, but I can't find it now. It might have been rebased, but maybe he has a copy of the old docs. |
@dnephin You could parse "link" into a "network connect --as" |
I think we'd rather keep them separate, since they function very differently, but technically we could do that, true. |
Thanks. If the alias as we defined here can be used with compatibility with links am all for it. |
@dnephin If this gets built out as an option for the
|
@delfuego we dont need to modify the |
I do not know exactly how the automatic service discovery is done in details with the multi-host overlay network driver, but IMHO: in a microservices architecture running under a Perhaps we could have an api like this one:
|
Also, I do not know if this issue is the right place to talk about this, but IMHO the
I ran a test on 3 boot2docker machine following the docker network demo and I tried to have two separate machine running a container with the same name on the same network. It failed and I received the following error output:
|
@secat I think this comes down to a proper discussion around discovery (beyond the current /etc/hosts functionality), and we should keep that in mind when implementing aliases. Note that when I say aliases, I'm really referring to the concept of giving a container a 2nd name (which is also what --link does) rather than alias in terms of /etc/hosts. |
+1 I think this is an absolutely necessary feature for many use cases (I posted a question about my use case on SO: http://stackoverflow.com/questions/33835469/docker-networking-auto-discovering-host-names-in-a-bridge-network). I think for most cases it would suffice to be able to customize the host name that is put in the Is there a good reason that the |
an alias feature is absolutly necessary! would be nice to be able to set aliases like we could with links - any progress on this? |
+1 . an alias feature is absolutly necessary! |
So, as @mavenugo pointed out, just giving aliases to containers won't be able to replace "link" functionality completely. I think links have already a very good UX that developers are already familiar to that we can just try to support in other than bridge networks. "Links" give aliases to "parent" containers to their "children" containers only, not globally. So for two different containers connected to the same network, the alias could resolve to different containers:
In this case you can't just give to both I would suggest using DNS search domains for the embedded docker DNS server to detect from which container the lookup is coming and resolve appropriately. In terms of UX, can't we just use I understand some type of alias functionality as being discussed here could act as a workaround in the short term, and compose could use it to "implement links", but can't we just try to implement that functionality natively on the server side? |
@fermayo I would argue that we should not support the example you gave. These should be separate networks. |
I think the 1-1 aliasing is a separately discussion. This issue is just to support "global aliases", which is the minimum required to support non-experimental networking in compose. I think the discussion about 1-1 aliasing is a much larger, and more controversial topic, so I'd like to keep it separate from "global aliases". |
While we're here, one important point of clarification to make:
When using My request is, if For aliases, we could use multiple ExampleConsider the following web:
image: nginx On A new network called Then, a new container is created using the API equivalent of:
We can see that the containers hostname is
And the containers
|
@dave-tucker When other containers join test network, Can they get last hostname in /etc/hosts ? Example:
|
@woshihaoren yep, we should probably move that discussion over to compose (e.g behaviour of scale with stateful/stateless services). From a "plumbing' standpoint, I think my proposal should work. |
@dave-tucker Yeah, I think your proposal should work. See what they think |
@cpuguy83 @dnephin In Tutum we do implement the example I gave above (cross host links) and I was hoping something similar could be implemented natively. We can discuss it on a separate thread. @dave-tucker For multiple A records for the same hostname you would need a proper DNS server (#767). |
Thanks everyone for the inputs. I added the milestone (as 0.6) which is the next major release for libnetwork (via Docker 1.10). This is absolutely required in order to have a clean integration with Compose. As @fermayo pointed out, though this proposal is independent of the implementation (/etc/hosts vs DNS), #767 does impact the finer details of the discussion. For example, supporting multiple A records is important in order to provide the round robin functionality for multiple aliases mapping to the same name, This is quite useful for number of scenarios including compose. We will add this as a requirement in #767. I think @dave-tucker has a valid point regarding @fermayo supporting 1:1 alias (similar to links) is going to complicate the design and hence am trying to see if this is a mandatory requirement ? With the concept of @dave-tucker @dnephin for the UX, I think @cpuguy83 suggestion of |
|
@mrjana @sanimej can you please share your views on this ? This is closely related to #767
@dnephin @dave-tucker Based on your previous comments, I guess 1:1 alias is not mandatory for compose. Is that correct ?
No reason. I was just thinking in terms of links where-in, the alias were specified dynamically when the child containers were brought up. Having said that, we can introduce |
@mavenugo Couldn't we have |
I guess there are some potential gotchas here tracking removed/re-created containers. |
I had no idea we populated Regarding @dave-tucker's proposal to use
Using multiple properties with a defined order of priority could work, but for the reasons of leakiness described by @dave-tucker, I really feel |
This was always the case with
Though @dave-tucker's point is valid regarding using The alias functionality being discussed here is very important for many cases (including Compose). Lets make sure we design it to address the Compose requirement and also other cases as raised by @fermayo. |
I think we are missing some data to back that up - will try and find some. |
From my personal experience, the alias is an important feature. In my previous job we spun up many fig / docker-compose projects on the same host. Using the service name within the project (or instance of a project), allowed for easily reuse basic configuration, and simple service "discovery" within a project (I.e., the database could be connected to using the |
@thaJeztah totally aggree with you! looking forward to the milestone, or any alternative solution with a good "how to port your linked container s to the new-feature" guides |
👍 |
see moby/moby#18699 for the proposal in docker/docker |
+1 I have an exact need for this right now. |
I made Docker image to have power of multi A records for one net-alias. https://hub.docker.com/r/nordluf/swarm-discovery/ It works, at least in my environment, with many identical microservices which I want to connect using one dns name . May be it can be useful for others. |
Is it closed because of moby/moby#18699? What's left? |
Yes. this issue must be closed. Thanks @sheerun for bringing it up. |
For anyone coming in late, see the compose file reference for "aliases":
|
We'd like a container to be able to join a network under different names, not just the container name.
Related: docker/compose#2312
The text was updated successfully, but these errors were encountered: