Skip to content
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 additional service network alias (project_name + service_name). #11257

Open
OsoianMarcel opened this issue Dec 8, 2023 · 1 comment
Open

Comments

@OsoianMarcel
Copy link

Description

By default, a service has 3 network aliases: container name, service name, container id.
Would be great to have one more default alias which would be computed from docker compose project name and service name. For example: project name: micro1, service name: app, so the alias would be: micro1-app.
This alias would help with solving the problem with DNS service name collisions when multiple Docker Compose projects are connected together with external networks.

Example:

docker-compose (A)
  services:
    app:
      networks:
        default:
    web:
      networks:
        default:
        common:
docker-compose (B)
  services:
    app:
      networks:
        common:
        default:

The service web from compose A calling service app may call his internal service app or external service app from compose B.

Having a default alias like docker compose project name and service name would resolve the problem.

Currently, without this feature, I see 2 solutions:

  1. make all service name unique in all docker compose projects;
  2. set unique alias names in all docker compose projects,

It there is another solution, please write in comments.

Thank you.

@djohnson-aperture
Copy link

Just running into this as well. Took me a long time to figure out that my requests to db were going to the other projects container instance, instead of the one in my current project... All because they share a unified external proxy that network so traefik can handle dynamic routing.

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

No branches or pull requests

4 participants