diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-05 05:51:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 05:51:19 -0400 |
commit | 7af4612d6b969329a78b4945c35a641449989a2d (patch) | |
tree | 1b4e70fa3cce85f9d0ab53ae0b3cd8fb97da0faf /libpod/container.go | |
parent | 97beca9e83ea5afee5f07249967cb1bdda2b9803 (diff) | |
parent | 1585b175dbf47e7ee0d5a26600aaec898ec5c26b (diff) | |
download | podman-7af4612d6b969329a78b4945c35a641449989a2d.tar.gz podman-7af4612d6b969329a78b4945c35a641449989a2d.tar.bz2 podman-7af4612d6b969329a78b4945c35a641449989a2d.zip |
Merge pull request #14059 from cdoern/clone
pass networks to container clone
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libpod/container.go b/libpod/container.go index 3e7ab7b0a..457b290b7 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -288,6 +288,15 @@ func (c *Container) Config() *ContainerConfig { return nil } + if c != nil { + networks, err := c.networks() + if err != nil { + return nil + } + + returnConfig.Networks = networks + } + return returnConfig } @@ -1260,7 +1269,10 @@ func (c *Container) NetworkMode() string { // Unlocked accessor for networks func (c *Container) networks() (map[string]types.PerNetworkOptions, error) { - return c.runtime.state.GetNetworks(c) + if c != nil && c.runtime != nil && c.runtime.state != nil { // can fail if c.networks is called from the tests + return c.runtime.state.GetNetworks(c) + } + return nil, nil } // getInterfaceByName returns a formatted interface name for a given |