docker / docker/compose

Add additional service network alias (project_name + service_name).

Open
#11,257 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature
Dominant language
Go
Stars
38.2k
Forks
5.8k
Avg merge
2d 14h
Merged PRs (30d)
55

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how Docker Compose assigns service network aliases and combines project and service names. Confirm the desired behavior against the multi-project external-network example, then define tests showing that the additional project-service alias is present without changing existing aliases.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, go
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.