mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-22 06:59:31 +08:00
Merge pull request #30 from estesp/missing-rootfs-check
Make startup errors a bit friendlier
This commit is contained in:
3
main.go
3
main.go
@@ -82,7 +82,6 @@ func main() {
|
||||
// default action is to execute a container
|
||||
app.Action = func(context *cli.Context) {
|
||||
if os.Geteuid() != 0 {
|
||||
cli.ShowAppHelp(context)
|
||||
logrus.Fatal("runc should be run as root")
|
||||
}
|
||||
spec, err := loadSpec(context.Args().First())
|
||||
@@ -91,7 +90,7 @@ func main() {
|
||||
}
|
||||
status, err := execContainer(context, spec)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
logrus.Fatalf("Container start failed: %v", err)
|
||||
}
|
||||
// exit with the container's exit status so any external supervisor is
|
||||
// notified of the exit with the correct exit status.
|
||||
|
7
run.go
7
run.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/codegangsta/cli"
|
||||
@@ -16,6 +17,12 @@ func execContainer(context *cli.Context, spec *LinuxSpec) (int, error) {
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
if _, err := os.Stat(config.Rootfs); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return -1, fmt.Errorf("Rootfs (%q) does not exist", config.Rootfs)
|
||||
}
|
||||
return -1, err
|
||||
}
|
||||
rootuid, err := config.HostUID()
|
||||
if err != nil {
|
||||
return -1, err
|
||||
|
Reference in New Issue
Block a user