diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 91164375b5..90420cc687 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -607,8 +607,6 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { if opts.InterfaceName == "" { return fmt.Errorf("network interface name cannot be an empty string: %w", define.ErrInvalidArg) } - // always add the short id as alias for docker compat - opts.Aliases = append(opts.Aliases, ctr.config.ID[:12]) optBytes, err := json.Marshal(opts) if err != nil { return fmt.Errorf("marshalling network options JSON for container %s: %w", ctr.ID(), err) diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index dcd0bd53e5..8c2583fea7 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -282,6 +282,8 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai return nil, errors.New("failed to find free network interface name") } } + // always add the short id as alias for docker compat + opts.Aliases = append(opts.Aliases, ctr.config.ID[:12]) normalizeNetworks[netName] = opts } diff --git a/libpod/sqlite_state_internal.go b/libpod/sqlite_state_internal.go index 7143978a3a..1aa39cbe1a 100644 --- a/libpod/sqlite_state_internal.go +++ b/libpod/sqlite_state_internal.go @@ -385,12 +385,6 @@ func (s *SQLiteState) rewriteContainerConfig(ctr *Container, newCfg *ContainerCo } func (s *SQLiteState) addContainer(ctr *Container) (defErr error) { - for net := range ctr.config.Networks { - opts := ctr.config.Networks[net] - opts.Aliases = append(opts.Aliases, ctr.config.ID[:12]) - ctr.config.Networks[net] = opts - } - configJSON, err := json.Marshal(ctr.config) if err != nil { return fmt.Errorf("marshalling container config json: %w", err)