From 3220b9a5aea95a88287c8d68b50d979bdd8ceb95 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Thu, 6 Apr 2023 14:30:42 +0000 Subject: [PATCH] Additional arguments for containers --- container.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/container.go b/container.go index 3365719..0a1df22 100644 --- a/container.go +++ b/container.go @@ -23,6 +23,8 @@ type container struct { UsrSrc string Boot string } + // Additional arguments + Args []string } func NewContainer(name string, timeout time.Duration) (c container, err error) { @@ -62,12 +64,17 @@ func (c container) Build(imagePath string) (output string, err error) { } func (c container) Run(workdir string, command string) (output string, err error) { - cmd := exec.Command("docker", "run", "--rm", + 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", - c.name, "bash", "-c", "cd /work && "+command) + "-v", c.Volumes.Boot+":/boot") + args = append(args, c.name, "bash", "-c", "cd /work && "+command) + + cmd := exec.Command("docker", args...) log.Debug().Msgf("%v", cmd)