Forbid exec a restarting container
Currently if we exec a restarting container, client will fail silently, and daemon will print error that container can't be found which is not a very meaningful prompt to user. This commit will stop user from exec a restarting container and gives more explicit error message. Signed-off-by: Zhang Wei <zhangwei555@huawei.com> Upstream-commit: 1d2208fed90da9ab72ded3b1c65bb2a71b66ce93 Component: engine
This commit is contained in:
@@ -52,6 +52,9 @@ func (d *Daemon) getExecConfig(name string) (*exec.Config, error) {
|
||||
if container.IsPaused() {
|
||||
return nil, derr.ErrorCodeExecPaused.WithArgs(container.ID)
|
||||
}
|
||||
if container.IsRestarting() {
|
||||
return nil, derr.ErrorCodeExecRestarting.WithArgs(container.ID)
|
||||
}
|
||||
return ec, nil
|
||||
}
|
||||
}
|
||||
@@ -76,6 +79,9 @@ func (d *Daemon) getActiveContainer(name string) (*container.Container, error) {
|
||||
if container.IsPaused() {
|
||||
return nil, derr.ErrorCodeExecPaused.WithArgs(name)
|
||||
}
|
||||
if container.IsRestarting() {
|
||||
return nil, derr.ErrorCodeExecRestarting.WithArgs(name)
|
||||
}
|
||||
return container, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user