summaryrefslogtreecommitdiff
path: root/libpod/container_validate.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_validate.go')
-rw-r--r--libpod/container_validate.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/libpod/container_validate.go b/libpod/container_validate.go
index 68cc095b7..fa809436e 100644
--- a/libpod/container_validate.go
+++ b/libpod/container_validate.go
@@ -115,5 +115,16 @@ func (c *Container) validate() error {
destinations[vol.Dest] = true
}
+ // Check that networks and network aliases match up.
+ ctrNets := make(map[string]bool)
+ for _, net := range c.config.Networks {
+ ctrNets[net] = true
+ }
+ for net := range c.config.NetworkAliases {
+ if _, ok := ctrNets[net]; !ok {
+ return errors.Wrapf(define.ErrNoSuchNetwork, "container tried to set network aliases for network %s but is not connected to the network", net)
+ }
+ }
+
return nil
}