You can only attach to running containers

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #98
Approved by: mheon
This commit is contained in:
Daniel J Walsh 2017-12-03 08:34:04 -05:00 committed by Atomic Bot
parent 95cb7a11f1
commit 1f482c9f1f
1 changed files with 3 additions and 5 deletions

View File

@ -598,11 +598,9 @@ func (c *Container) Attach(noStdin bool, keys string, attached chan<- bool) erro
return err return err
} }
// TODO is it valid to attach to a frozen container? if c.state.State != ContainerStateCreated &&
if c.state.State == ContainerStateUnknown || c.state.State != ContainerStateRunning {
c.state.State == ContainerStateConfigured || return errors.Wrapf(ErrCtrStateInvalid, "can only attach to created or running containers")
c.state.State == ContainerStatePaused {
return errors.Wrapf(ErrCtrStateInvalid, "can only attach to created, running, or stopped containers")
} }
// Check the validity of the provided keys first // Check the validity of the provided keys first