moby / moby/libnetwork

resolve service container hostname

Open
#2,549 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

how about to resolve service container hostname?
for example as follow

diff --git a/agent.go b/agent.go
index 4a5c2156..162d4b1f 100644
--- a/agent.go
+++ b/agent.go
@@ -640,6 +640,7 @@ func (ep *endpoint) addServiceInfoToCluster(sb *sandbox) error {
                if n.ingress {
                        ingressPorts = ep.ingressPorts
                }
+               ep.myAliases = append(ep.myAliases, sb.config.hostName)
                if err := c.addServiceBinding(ep.svcName, ep.svcID, n.ID(), ep.ID(), name, ep.virtualIP, ingressPorts, ep.svcAliases, ep.myAliases, ep.Iface().Address().IP, "addServiceInfoToCluster"); err != nil {
                        return err
                }

it works with templating hostname as {{.Service.Name}}-{{.Task.Slot}} or {{.Service.Name}}-{{.Node.Hostname}}

Contributor guide

No contributing guide indexed for this repository

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 in agent.go at endpoint.addServiceInfoToCluster, especially the addServiceBinding call and the proposed sb.config.hostName alias. Compare the existing service alias handling with the hostname templates shown in the issue, then verify that service container hostnames resolve as expected without breaking current bindings.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.