Skip to content

Add dnsnames field & fix alias field - #29227

Merged
baude merged 1 commit into
podman-container-tools:mainfrom
ashley-cui:dnsnames
Aug 4, 2026
Merged

Add dnsnames field & fix alias field#29227
baude merged 1 commit into
podman-container-tools:mainfrom
ashley-cui:dnsnames

Conversation

@ashley-cui

@ashley-cui ashley-cui commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Docker now reserves alias specfically for user-defined aliases, and uses another field, dnsnames, to hold all aliases, including container ID and name.
Part of docker v1.45 compat work, but this touches the cli too, since they updated it there too.

The NetworkSettings.Network.Aliases field in the `podman inspect` command and in returned in calls to GET /containers/{name:.*}/json API no longer contains the short container ID, and only contains user-provided network aliases. A new field, NetworkSettings.Network.DNSNames contains all aliases, container ID and name.

Comment thread libpod/runtime_ctr.go Outdated
@ashley-cui
ashley-cui marked this pull request as draft July 20, 2026 17:43
@ashley-cui
ashley-cui force-pushed the dnsnames branch 2 times, most recently from fd925fb to 7f92308 Compare July 24, 2026 14:21
@ashley-cui
ashley-cui marked this pull request as ready for review July 24, 2026 14:35

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approach looks good to me but tests are failing

Comment thread libpod/networking_common.go Outdated
Comment on lines +76 to +77
networks := make([]types.NamedPerNetworkOptions, len(opts.Networks))
copy(networks, opts.Networks)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a copy here, the options we are given can be expected to be modified. This should not cause any negative downsides AFAIK

Comment thread libpod/networking_common.go Outdated
networks := make([]types.NamedPerNetworkOptions, len(opts.Networks))
copy(networks, opts.Networks)
for i := range networks {
networks[i].Aliases = append(slices.Clone(networks[i].Aliases), getExtraNetworkAliases(c)...)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code could use slices.Concat() instead of the append and then could also get rid of that clone as concat will allocate a new slice always

Comment thread libpod/networking_common.go Outdated
netInfo := new(define.InspectAdditionalNetwork)
netInfo.NetworkID = getNetworkID(net.Name)
netInfo.Aliases = net.Aliases
netInfo.DNSNames = append(append([]string{c.Name()}, net.Aliases...), getExtraNetworkAliases(c)...)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here and for the other nested appends consider using slices.Concat instead

@ashley-cui
ashley-cui force-pushed the dnsnames branch 2 times, most recently from 884e420 to d519dd4 Compare July 28, 2026 13:04

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks
@mheon PTAL

@simek-m

simek-m commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Hi,
I completely missed this PR and independently opened a PR based on the v1.44 changelog adding the DnsNames too, my bad.

Comparing it apart from much better tests, different approach how the DnsNames field in the compat endpoint gets populated and change in the Aliases semantics, I noticed three other differences that I wanted to discuss:

  • I used getNetworkPodName(c) instead of c.Name(). Not sure what's more correct.
  • I deduplicated the DNSNames based on the Docker (Moby) implementation. When I test that, it looks like this in this branch:
{
  "Networks": {
    "podman": {
      ...
      "Aliases": [
        "844f6d6ce177"
      ],
      "DNSNames": [
        "dnstest",
        "844f6d6ce177",
        "844f6d6ce177"
      ]
    }
  }
  • The JIRA ticket also lists the libpod endpoint GET /libpod/containers/json to have DNSNames added (me adding that, also affected CLI).

Thanks.

@ashley-cui

Copy link
Copy Markdown
Contributor Author

I think the second difference comes in because in 1.44 dnsnames are added, and in 1.45 alias is reserved exclusively for user-defined names? So in this PR aliases are empty and dont contain the short container ID unless the alias is set by the user using a option. And since the fields are changed in InspectAdditionalNetwork, the cli and libpod api should both be updated

@simek-m

simek-m commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

I think the second difference comes in because in 1.44 dnsnames are added, and in 1.45 alias is reserved exclusively for user-defined names? So in this PR aliases are empty and dont contain the short container ID unless the alias is set by the user using a option. And since the fields are changed in InspectAdditionalNetwork, the cli and libpod api should both be updated

Yes, I also understand it like you.
Sorry for the confusion, the output was from your branch's podman, but the container was created with my branch's podman and that's why the Aliases and short ID was there.

What I meant was only the duplicate value that would Docker deduplicate. Maybe it's a non-issue, though.

I'm not sure about the libpod endpoint:

➜  curl -s http://localhost:8080/v6.0.0/libpod/containers/json | jq .
[
  {
    "AutoRemove": false,
    "Command": [
      "top"
    ],
    "Created": "2026-07-31T16:19:20.388670122+02:00",
    "CreatedAt": "",
    "CIDFile": "",
    "Exited": false,
    "ExitedAt": -62135596800,
    "ExitCode": 0,
    "ExposedPorts": null,
    "Id": "2c58132268f74f004b6969e10b9998f434850702456bec011d00acfc2a3322cd",
    "Image": "docker.io/library/alpine:latest",
    "ImageID": "1991bd789d7184290c3cce84fd6af068b8b745e9bddf178661ce7f5ecf68135c",
    "IsInfra": false,
    "Labels": null,
    "Mounts": [],
    "Names": [
      "dnstest"
    ],
    "Namespaces": {},
    "Networks": [
      "podman"
    ],
    "Pid": 512040,
    "Pod": "",
    "PodName": "",
    "Ports": null,
    "Restarts": 0,
    "Size": null,
    "StartedAt": 1785507560,
    "State": "running",
    "Status": ""
  }
]

For comparison:

➜  curl -s http://localhost:8080/v6.0.0/libpod/containers/json | jq .
[
  {
    ...
    "Names": [
      "dnstest"
    ],
    "Namespaces": {},
    "Networks": [
      "podman"
    ],
    "DNSNames": {
      "podman": [
        "dnstest",
        "844f6d6ce177"
      ]
    },
    ...
  }
]

@ashley-cui

Copy link
Copy Markdown
Contributor Author

Oh maybe not then. I'll update the libpod endpoint. I don't think we need to worry about dedup?

@simek-m

simek-m commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Oh maybe not then. I'll update the libpod endpoint. I don't think we need to worry about dedup?

Yeah, I think that with your other changes it's less of an issue. You can probably set multiple same aliases (haven't tried that), but it's a completely minor thing.

Edit:

Yes, you can, but it's on you if you set the same alias multiple times.

{
  "Networks": {
    "podman": {
      ...
      "Aliases": [
        "alias",
        "alias"
      ],
      ...
      "DNSNames": [
        "dnstest",
        "alias",
        "alias",
        "19c1e70a47f0"
      ]
    }
  }
}

@ashley-cui

Copy link
Copy Markdown
Contributor Author

Looks like the PR in its current state does have this behavior in the libpod endpoint:

curl -s --unix-socket /tmp/podman-test.sock http://d/v6.0.0/libpod/containers/dnscontainer/json | jq '.NetworkSettings.Networks.dnstest |  {Aliases, DNSNames}'
{
  "Aliases": [
    "myalias"
  ],
  "DNSNames": [
    "dnscontainer",
    "myalias",
    "e21b70f3817a",
    "myhostname"
  ]
}

Re-pushed for de-dup though

@simek-m PTAL, thanks!

Docker now reserves alias specfically for user-defined aliases, and uses another field, dnsnames, to hold all aliases, including container ID and name.
Part of docker v1.45 compat work, but this touches the cli too, since they updated it there too.

Signed-off-by: Ashley Cui <acui@redhat.com>
@simek-m

simek-m commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Looks like the PR in its current state does have this behavior in the libpod endpoint:

curl -s --unix-socket /tmp/podman-test.sock http://d/v6.0.0/libpod/containers/dnscontainer/json | jq '.NetworkSettings.Networks.dnstest |  {Aliases, DNSNames}'
{
  "Aliases": [
    "myalias"
  ],
  "DNSNames": [
    "dnscontainer",
    "myalias",
    "e21b70f3817a",
    "myhostname"
  ]
}

Re-pushed for de-dup though

@simek-m PTAL, thanks!

Yes, re-tested and it looks all correct. I was wrong about libpod/containers/json, it's just libpod/containers/dnscontainer/json that should have DNSNames, sorry. Deduplication works too, thanks.

@ashley-cui

Copy link
Copy Markdown
Contributor Author

@podman-container-tools/podman-maintainers PTAL and merge

@baude

baude commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

LGTM

@baude
baude merged commit 80bf6e6 into podman-container-tools:main Aug 4, 2026
121 of 124 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants