Maros Ondrejicka | 11a03e9 | 2022-12-01 09:56:37 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "github.com/edwarnicke/exechelper" |
| 7 | ) |
| 8 | |
| 9 | type Container struct { |
| 10 | name string |
| 11 | } |
| 12 | |
| 13 | func (c *Container) run() error { |
| 14 | if c.name == "" { |
| 15 | return fmt.Errorf("create volume failed: container name is blank") |
| 16 | } |
| 17 | |
| 18 | exechelper.Run(fmt.Sprintf("mkdir -p /tmp/%s/sync", c.name)) |
| 19 | syncPath := fmt.Sprintf("-v /tmp/%s/sync:/tmp/sync", c.name) |
| 20 | cmd := "docker run --cap-add=all -d --privileged --network host --rm " |
| 21 | cmd += syncPath |
| 22 | cmd += " --name " + c.name + " hs-test/vpp" |
| 23 | fmt.Println(cmd) |
| 24 | err := exechelper.Run(cmd) |
| 25 | if err != nil { |
| 26 | return fmt.Errorf("create volume failed: %s", err) |
| 27 | } |
| 28 | |
| 29 | return nil |
| 30 | } |
| 31 | |