Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ func (d *Daemon) Run() error {
d.networkMgr = networkMgr
containerMgr.(*mgr.ContainerManager).NetworkMgr = networkMgr

// Notes(ziren): we must call containerMgr.Restore after NetworkMgr initialized,
// otherwize will panic
if err := containerMgr.Restore(ctx); err != nil {
return err
}

if err := d.addSystemLabels(); err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion daemon/mgr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ import (
type ContainerMgr interface {
// 1. the following functions are related to regular container management

// Restore containers from meta store to memory and recover those container.
Restore(ctx context.Context) error

// Create a new container.
Create(ctx context.Context, name string, config *types.ContainerCreateConfig) (*types.ContainerCreateResp, error)

Expand Down Expand Up @@ -176,7 +179,7 @@ func NewContainerManager(ctx context.Context, store *meta.Store, cli ctrd.APICli

go mgr.execProcessGC()

return mgr, mgr.Restore(ctx)
return mgr, nil
}

// Restore containers from meta store to memory and recover those container.
Expand Down