diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-09-28 10:03:17 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-28 10:03:17 -0400 |
commit | 2d22d17066aae4c357aff7015220cd4095d996f8 (patch) | |
tree | 153f1cb64bd9bbf913ac3c45f32605d44c4298e5 /libpod/runtime_ctr.go | |
parent | cc23e059d9537360d0eb4c16c4f0598efd8ecb0d (diff) | |
parent | 1c8926285d1ecdfe201fe68896657573dcdc22b7 (diff) | |
download | podman-2d22d17066aae4c357aff7015220cd4095d996f8.tar.gz podman-2d22d17066aae4c357aff7015220cd4095d996f8.tar.bz2 podman-2d22d17066aae4c357aff7015220cd4095d996f8.zip |
Merge pull request #11751 from Luap99/net-alias
always add short container id as net alias
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r-- | libpod/runtime_ctr.go | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 9a4dbf626..93bfdd54b 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -234,13 +234,6 @@ func (r *Runtime) newContainer(ctx context.Context, rSpec *spec.Spec, options .. } func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Container, retErr error) { - // Validate the container - if err := ctr.validate(); err != nil { - return nil, err - } - if ctr.config.IsInfra { - ctr.config.StopTimeout = 10 - } // normalize the networks to names // ocicni only knows about cni names so we have to make // sure we do not use ids internally @@ -265,11 +258,26 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai if err != nil { return nil, err } + 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) + } netAliases[netName] = aliases } ctr.config.NetworkAliases = netAliases } + // Validate the container + if err := ctr.validate(); err != nil { + return nil, err + } + if ctr.config.IsInfra { + ctr.config.StopTimeout = 10 + } + // Inhibit shutdown until creation succeeds shutdown.Inhibit() defer shutdown.Uninhibit() |