Skip to content

Commit 98d6350

Browse files
committed
Not exec a container from stopped state
Signed-off-by: rajasec <[email protected]>
1 parent c92d105 commit 98d6350

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

exec.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"strings"
1111

12+
"github.com/opencontainers/runc/libcontainer"
1213
"github.com/opencontainers/runc/libcontainer/utils"
1314
"github.com/opencontainers/runtime-spec/specs-go"
1415
"github.com/urfave/cli"
@@ -101,6 +102,13 @@ func execProcess(context *cli.Context) (int, error) {
101102
if err != nil {
102103
return -1, err
103104
}
105+
status, err := container.Status()
106+
if err != nil {
107+
return -1, err
108+
}
109+
if status == libcontainer.Stopped {
110+
return -1, fmt.Errorf("cannot exec a container that has run and stopped")
111+
}
104112
path := context.String("process")
105113
if path == "" && len(context.Args()) == 1 {
106114
return -1, fmt.Errorf("process args cannot be empty")

0 commit comments

Comments
 (0)