summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-23 19:39:25 -0500
committerGitHub <noreply@github.com>2021-02-23 19:39:25 -0500
commit49fa19dff6717e419ebbaba029e84cbc5bd97904 (patch)
tree1c21ed0e38bed17a186e9e6a9e1fde0aebbb77c1 /libpod
parentca0af71befa7e8408d83c59511e289cb57cf3c6d (diff)
parentf152f9cf0940131cc74e99d42a498a2de4669ef5 (diff)
downloadpodman-49fa19dff6717e419ebbaba029e84cbc5bd97904.tar.gz
podman-49fa19dff6717e419ebbaba029e84cbc5bd97904.tar.bz2
podman-49fa19dff6717e419ebbaba029e84cbc5bd97904.zip
Merge pull request #9497 from Luap99/fix-9496
Network connect error if net mode is not bridge
Diffstat (limited to 'libpod')
-rw-r--r--libpod/networking_linux.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index c1b2c694d..0526e646e 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -1134,6 +1134,11 @@ func (w *logrusDebugWriter) Write(p []byte) (int, error) {
// NetworkDisconnect removes a container from the network
func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) error {
+ // only the bridge mode supports cni networks
+ if !c.config.NetMode.IsBridge() {
+ return errors.Errorf("network mode %q is not supported", c.config.NetMode)
+ }
+
networks, err := c.networksByNameIndex()
if err != nil {
return err
@@ -1190,6 +1195,11 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
// ConnectNetwork connects a container to a given network
func (c *Container) NetworkConnect(nameOrID, netName string, aliases []string) error {
+ // only the bridge mode supports cni networks
+ if !c.config.NetMode.IsBridge() {
+ return errors.Errorf("network mode %q is not supported", c.config.NetMode)
+ }
+
networks, err := c.networksByNameIndex()
if err != nil {
return err