Skip to content

Commit

Permalink
run -ti现在成功挂载了,但pwd显示不是/,而是/var/lib/,需要修复
Browse files Browse the repository at this point in the history
  • Loading branch information
taikulawo committed Sep 6, 2019
1 parent ba671a6 commit 5532fdb
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "WWCDocker",
"type": "go",
Expand Down
5 changes: 3 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/urfave/cli"
)

// wwcdocker -ti ubuntu bash
// wwcdocker -ti busybox bash
var RunCommand = cli.Command{
Name: "run",
Usage: "create a new container from given image",
Expand Down Expand Up @@ -106,7 +106,7 @@ var InitCommand = cli.Command{
// 可算搞明白僵尸进程了
// 可算坑死我了 :(
b, err := common.ReadFromFd(3)
log.Debugf("Read from parent process %s", b)
log.Infof("Read from parent process %s", b)
if err != nil {
log.Error(err)
return err
Expand All @@ -125,6 +125,7 @@ var InitCommand = cli.Command{
}
// env 在 容器里已经注入过了,这里 Environ 包含着 user 注入进来的 env
if err := syscall.Exec(absolutePath, args, os.Environ()); err != nil {
log.Error(err)
return fmt.Errorf("Fail to Exec process in container. Error: %v", err)
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion container/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ func GetContainerProcess(info *ContainerInfo) (*exec.Cmd, *os.File) {
info.FilePath["logFolder"] = logDir
info.FilePath["logFile"] = logFilePath
}
NewWorkspace(ContainerMountRoot,info.ID,info.VolumePoints)
cwd := NewWorkspace(ContainerMountRoot,info.ID,info.VolumePoints)
cmd.Dir = cwd
return cmd, writePipe
}

Expand Down
3 changes: 2 additions & 1 deletion container/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func createMountPoint(mountpath, wlayerpath, rlayerpath string) error {
return err
}
dirs := fmt.Sprintf("dirs=%s:%s", wlayerpath, rlayerpath)
if err := exec.Command("mount", "-t", "aufs", "-o", dirs, "none", mountpath).Run(); err != nil {
if _, err := exec.Command("mount", "-t", "aufs", "-o", dirs, "none", mountpath).CombinedOutput(); err != nil {
log.Error(err)
return err
}
return nil
Expand Down
1 change: 1 addition & 0 deletions main.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func main() {
app.Before = func(ctx *cli.Context) error {
log.SetReportCaller(false)
log.SetOutput(os.Stdout)
// log.SetLevel(log.DebugLevel)
return nil
}
if err := app.Run(os.Args); err != nil {
Expand Down
Empty file modified scripts/clean.sh
100644 → 100755
Empty file.

0 comments on commit 5532fdb

Please sign in to comment.