mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #21630 from LK4D4/fix_create_list_races
daemon: register container as late as possible
This commit is contained in:
commit
34e05f5cb1
1 changed files with 6 additions and 6 deletions
|
@ -74,8 +74,8 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe
|
|||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
if err := daemon.ContainerRm(container.ID, &types.ContainerRmConfig{ForceRemove: true}); err != nil {
|
||||
logrus.Errorf("Clean up Error! Cannot destroy container %s: %v", container.ID, err)
|
||||
if err := daemon.cleanupContainer(container, true); err != nil {
|
||||
logrus.Errorf("failed to cleanup container on create error: %v", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -91,9 +91,6 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := daemon.Register(container); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rootUID, rootGID, err := idtools.GetRootUIDGID(daemon.uidMaps, daemon.gidMaps)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -126,10 +123,13 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := container.ToDiskLocking(); err != nil {
|
||||
if err := container.ToDisk(); err != nil {
|
||||
logrus.Errorf("Error saving new container to disk: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if err := daemon.Register(container); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
daemon.LogContainerEvent(container, "create")
|
||||
return container, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue