1
0
Fork 0

Allow to disable container volumes mount

master
dump_stack() 2023-04-07 17:35:00 +00:00
parent 056e38698e
commit c3cf25e523
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
1 changed files with 12 additions and 5 deletions

View File

@ -188,11 +188,18 @@ func (c container) Run(workdir string, command string) (output string, err error
var args []string
args = append(args, "run", "--rm")
args = append(args, c.Args...)
args = append(args,
"-v", workdir+":/work",
"-v", c.Volumes.LibModules+":/lib/modules",
"-v", c.Volumes.UsrSrc+":/usr/src",
"-v", c.Volumes.Boot+":/boot")
if workdir != "" {
args = append(args, "-v", workdir+":/work")
}
if c.Volumes.LibModules != "" {
args = append(args, "-v", c.Volumes.LibModules+":/lib/modules")
}
if c.Volumes.UsrSrc != "" {
args = append(args, "-v", c.Volumes.UsrSrc+":/usr/src")
}
if c.Volumes.Boot != "" {
args = append(args, "-v", c.Volumes.Boot+":/boot")
}
args = append(args, c.name, "bash", "-c", "cd /work && "+command)
cmd := exec.Command("docker", args...)