package main

import (
	"os"
	"os/exec"
)

// docker runs docker command
func docker(args ...string) error {
	cmd := exec.Command("docker", args...)
	cmd.Stderr = os.Stdout // ioutil.Discard
	cmd.Stdout = os.Stdout // ioutil.Discard

	if err := cmd.Run(); err != nil {
		return err
	}

	return nil
}

package main

import (
	"io"
	"io/ioutil"
	"os/exec"
)

type Docker struct {
	OutStream io.Writer
	Discard   bool
}

// docker runs docker command
func (d *Docker) execute(args ...string) error {
	cmd := exec.Command("docker", args...)
	cmd.Stderr = d.OutStream
	cmd.Stdout = d.OutStream

	if d.Discard {
		cmd.Stderr = ioutil.Discard
		cmd.Stdout = ioutil.Discard
	}

	if err := cmd.Run(); err != nil {
		return err
	}

	return nil
}

Allow to output to Discard
Allow to output to Discard
