-
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
Add option to remove service name as default alias on networks #8223
Comments
In short, I'm looking for a flag that would toggle the logic in Lines 805 to 810 in 5b7851f
into something that looks more like def _get_aliases(self, network, container=None):
return list(
({container.short_id} if container else set()) |
set(network.get('aliases', ()) or [self.name])
) where it would only use the configured aliases if present and non-empty, and default to the service name if no custom aliases are provided. |
Issue: docker#8223 Signed-off-by: David Li <jiawei.davidli@gmail.com>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I really like the idea of breaking the website name in definition from the host name on a shared network and this functionality would be very helpful. I also have a second scenario where I would see this functionality. When I work on several branches using worktree, I wish I could switch to another branch without having to turn off the containers of the other branch. Currently, it is not possible, especially since the definition of these services is almost identical. An additional, huge advantage would be the ability to define / overwrite these aliases in the override file. |
This issue has been automatically marked as not stale anymore due to the recent activity. |
Issue: docker#8223 Signed-off-by: David Li <jiawei.davidli@gmail.com>
Issue: docker#8223 Signed-off-by: David Li <jiawei.davidli@gmail.com>
Issue: docker#8223 Signed-off-by: David Li <jiawei.davidli@gmail.com>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'd like to keep this alive. This issue is still a problem on the latest release, and no effective solution is available. |
This issue has been automatically marked as not stale anymore due to the recent activity. |
Issue: docker#8223 Signed-off-by: David Li <jiawei.davidli@gmail.com>
I'm seeing exactly this too, and it took me a while to track down, since I assumed that if I provided a list of aliases the automatically generated ones wouldn't be present. Is there anywhere in the documentation that states that the generated aliases will still be added in addition to the ones specified explicitly? |
While there is a workaround for this "just don't use same names". It's annoying since it requires you to be aware of the names used in different stacks (when you have generic router that routes traffic domain based to multiple stacks). This seems like relatively small development effort, that would significantly ease up our DevOps. I'm talking about use case in Swarm mode. |
any workaround on this issue? |
Hey, i am facing the same issue. |
I just ran into this - see my write-up at Stack Overflow. I certainly think that the feature requested here and / or better documentation and warnings would be desirable. |
Just got the same problem |
version: '3' networks: services: |
(Copied from https://forums.docker.com/t/add-option-to-remove-service-name-as-default-alias-on-networks/106172 after I realized this was a compose-specific request)
I am facing an issue where two separate docker compose projects sharing a common externally defined docker network would encounter DNS name collisions when both projects have a service with the same name.
Example Setup:
project1/docker-compose.yml:
project2/docker-compose.yml:
Problem:
shared_network
is an externally created docker network common to bothproject1
andproject2
. When I spin both projects up, both theproject1_database_1
andproject2_database_1
containers are aliased todatabase
onshared_network
, in addition to the custom aliases provided.Making things worse, when I try to communicate with
database
on other containers inproject1
orproject2
who are also connected toshared_network
, it's a tossup whether I'll be talking withproject1_database_1
orproject2_database_1
.Desired Outcome for Example:
project1_database_1
andproject2_database_1
should be known by onshared_network
are the custom aliases provided.project1
:database
should always point toproject1_database_1
over theproject1_app_internal
networkproject1-database
should always point toproject1_database_1
over theshared_network
networkproject2-database
should always point toproject2_database_1
over theshared_network
networkproject2
Feature Request:
Currently, the problematic behavior occurs because of this interaction in the Docker-compose documentation:
Other containers on the same network can use *either* the service name or this alias to connect to one of the service’s containers.
(emphasis mine)I would like to have an option at either a service level or a network level to tell Docker Compose not to add the service name as an alias when attaching a network.
The text was updated successfully, but these errors were encountered: