mirror of
https://github.com/containers/podman.git
synced 2025-10-17 19:24:04 +08:00
move network alias validation to container create
Podman 4.0 currently errors when you use network aliases for a network which has dns disabled. Because the error happens on network setup this can cause regression for old working containers. The network backend should not validate this. Instead podman should check this at container create time and also for network connect. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -1262,6 +1262,14 @@ func (c *Container) NetworkConnect(nameOrID, netName string, aliases []string) e
|
||||
// get network status before we connect
|
||||
networkStatus := c.getNetworkStatus()
|
||||
|
||||
network, err := c.runtime.network.NetworkInspect(netName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !network.DNSEnabled && len(aliases) > 0 {
|
||||
return errors.Wrapf(define.ErrInvalidArg, "cannot set network aliases for network %q because dns is disabled", netName)
|
||||
}
|
||||
|
||||
if err := c.runtime.state.NetworkConnect(c, netName, aliases); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user