Can define volumes to collect artifacts

This commit is contained in:
nemunaire 2021-05-02 19:27:30 +02:00
commit e3a911cd05
6 changed files with 149 additions and 10 deletions

View file

@ -6,6 +6,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
oci "github.com/opencontainers/image-spec/specs-go/v1"
@ -29,7 +30,7 @@ func Ps() ([]types.Container, error) {
return containers, nil
}
func Run(image string, cmd []string) (string, error) {
func Run(image string, cmd []string, mounts []mount.Mount) (string, error) {
cli, err := newCli()
if err != nil {
return "", err
@ -42,8 +43,13 @@ func Run(image string, cmd []string) (string, error) {
AttachStderr: true,
Image: image,
Cmd: cmd,
Volumes: map[string]struct{}{
"/data": {},
},
},
&container.HostConfig{
Mounts: mounts,
},
&container.HostConfig{},
&network.NetworkingConfig{},
&oci.Platform{
Architecture: "amd64",