mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +08:00
Merge pull request #12991 from Luap99/aliases
container create: do not check for network dns support
This commit is contained in:
@ -1198,13 +1198,6 @@ func (c *Container) NetworkConnect(nameOrID, netName string, netOpts types.PerNe
|
|||||||
// get network status before we connect
|
// get network status before we connect
|
||||||
networkStatus := c.getNetworkStatus()
|
networkStatus := c.getNetworkStatus()
|
||||||
|
|
||||||
network, err := c.runtime.network.NetworkInspect(netName)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !network.DNSEnabled && len(netOpts.Aliases) > 0 {
|
|
||||||
return errors.Wrapf(define.ErrInvalidArg, "cannot set network aliases for network %q because dns is disabled", netName)
|
|
||||||
}
|
|
||||||
// always add the short id as alias for docker compat
|
// always add the short id as alias for docker compat
|
||||||
netOpts.Aliases = append(netOpts.Aliases, c.config.ID[:12])
|
netOpts.Aliases = append(netOpts.Aliases, c.config.ID[:12])
|
||||||
|
|
||||||
|
@ -254,15 +254,6 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(opts.Aliases) > 0 {
|
|
||||||
network, err := r.network.NetworkInspect(netName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !network.DNSEnabled {
|
|
||||||
return nil, errors.Wrapf(define.ErrInvalidArg, "cannot set network aliases for network %q because dns is disabled", netName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// assign interface name if empty
|
// assign interface name if empty
|
||||||
if opts.InterfaceName == "" {
|
if opts.InterfaceName == "" {
|
||||||
for i < 100000 {
|
for i < 100000 {
|
||||||
|
@ -867,4 +867,17 @@ EXPOSE 2004-2005/tcp`, ALPINE)
|
|||||||
Expect(inspectOut[0].NetworkSettings.Networks).To(HaveLen(1))
|
Expect(inspectOut[0].NetworkSettings.Networks).To(HaveLen(1))
|
||||||
Expect(inspectOut[0].NetworkSettings.Networks).To(HaveKey("podman"))
|
Expect(inspectOut[0].NetworkSettings.Networks).To(HaveKey("podman"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// see https://github.com/containers/podman/issues/12972
|
||||||
|
It("podman run check network-alias works on networks without dns", func() {
|
||||||
|
net := "dns" + stringid.GenerateNonCryptoID()
|
||||||
|
session := podmanTest.Podman([]string{"network", "create", "--disable-dns", net})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
defer podmanTest.removeCNINetwork(net)
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
|
||||||
|
session = podmanTest.Podman([]string{"run", "--network", net, "--network-alias", "abcdef", ALPINE, "true"})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
Expect(session).Should(Exit(0))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user