From 4f9b1ae62553efb2f88ec143ed0782585e7d8d51 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 9 Jul 2018 15:20:43 -0400 Subject: Allow Init() on stopped containers Signed-off-by: Matthew Heon Closes: #1068 Approved by: baude --- libpod/container_api.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/container_api.go b/libpod/container_api.go index f4613534c..a3756ac5f 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -29,7 +29,8 @@ func (c *Container) Init(ctx context.Context) (err error) { } } - if c.state.State != ContainerStateConfigured { + if !(c.state.State == ContainerStateConfigured || + c.state.State == ContainerStateStopped) { return errors.Wrapf(ErrCtrExists, "container %s has already been created in runtime", c.ID()) } @@ -53,6 +54,12 @@ func (c *Container) Init(ctx context.Context) (err error) { } }() + if c.state.State == ContainerStateStopped { + // Reinitialize the container + return c.reinit(ctx) + } + + // Initialize the container for the first time return c.init(ctx) } -- cgit v1.2.3-54-g00ecf