func volume(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) == 0 {
		return errAtLeastOneArgument("VOLUME")
	}
	if b.RunConfig.Volumes == nil {
		b.RunConfig.Volumes = map[string]struct{}{}
	}
	for _, v := range args {
		v = strings.TrimSpace(v)
		if v == "" {
			return fmt.Errorf("Volume specified can not be an empty string")
		}
		b.RunConfig.Volumes[v] = struct{}{}
		b.PendingVolumes.Add(v)
	}
	return nil
}
VOLUME /foo

Expose the volume /foo for use. Will also accept the JSON array form.
package imagebuilder
import (
	"flag"
	"fmt"
	"os"
	"path/filepath"
	"regexp"
	"runtime"
	"strconv"
	"strings"
	docker "github.com/fsouza/go-dockerclient"
	"github.com/containerd/containerd/platforms"
	"github.com/openshift/imagebuilder/signal"
	"github.com/openshift/imagebuilder/strslice"
)
var (
	obRgex = regexp.MustCompile(`(?i)^\s*ONBUILD\s*`)
)
var localspec = platforms.DefaultSpec()
var builtinBuildArgs = map[string]string{
	"TARGETPLATFORM": localspec.OS + "/" + localspec.Architecture,
	"TARGETOS":       localspec.OS,
	"TARGETARCH":     localspec.Architecture,
	"TARGETVARIANT":  localspec.Variant,
	"BUILDPLATFORM":  localspec.OS + "/" + localspec.Architecture,
	"BUILDOS":        localspec.OS,
	"BUILDARCH":      localspec.Architecture,
	"BUILDVARIANT":   localspec.Variant,
}
func init() {
	if localspec.Variant != "" {
		builtinBuildArgs["TARGETPLATFORM"] = builtinBuildArgs["TARGETPLATFORM"] + "/" + localspec.Variant
		builtinBuildArgs["BUILDPLATFORM"] = builtinBuildArgs["BUILDPLATFORM"] + "/" + localspec.Variant
	}
}
func env(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) == 0 {
		return errAtLeastOneArgument("ENV")
	}
	if len(args)%2 != 0 {
		return errTooManyArguments("ENV")
	}
	for j := 0; j < len(args); j++ {
		newVar := []string{args[j] + "=" + args[j+1]}
		b.RunConfig.Env = mergeEnv(b.RunConfig.Env, newVar)
		b.Env = mergeEnv(b.Env, newVar)
		j++
	}
	return nil
}
func maintainer(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) != 1 {
		return errExactlyOneArgument("MAINTAINER")
	}
	b.Author = args[0]
	return nil
}
func label(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) == 0 {
		return errAtLeastOneArgument("LABEL")
	}
	if len(args)%2 != 0 {
		return errTooManyArguments("LABEL")
	}
	if b.RunConfig.Labels == nil {
		b.RunConfig.Labels = map[string]string{}
	}
	for j := 0; j < len(args); j++ {
		b.RunConfig.Labels[args[j]] = args[j+1]
		j++
	}
	return nil
}
func add(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) < 2 {
		return errAtLeastOneArgument("ADD")
	}
	var chown string
	var chmod string
	last := len(args) - 1
	dest := makeAbsolute(args[last], b.RunConfig.WorkingDir)
	userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env)
	for _, a := range flagArgs {
		arg, err := ProcessWord(a, userArgs)
		if err != nil {
			return err
		}
		switch {
		case strings.HasPrefix(arg, "--chown="):
			chown = strings.TrimPrefix(arg, "--chown=")
		case strings.HasPrefix(arg, "--chmod="):
			chmod = strings.TrimPrefix(arg, "--chmod=")
			err = checkChmodConversion(chmod)
			if err != nil {
				return err
			}
		default:
			return fmt.Errorf("ADD only supports the --chmod=<permissions> and the --chown=<uid:gid> flag")
		}
	}
	b.PendingCopies = append(b.PendingCopies, Copy{Src: args[0:last], Dest: dest, Download: true, Chown: chown, Chmod: chmod})
	return nil
}
func dispatchCopy(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) < 2 {
		return errAtLeastOneArgument("COPY")
	}
	last := len(args) - 1
	dest := makeAbsolute(args[last], b.RunConfig.WorkingDir)
	var chown string
	var chmod string
	var from string
	userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env)
	for _, a := range flagArgs {
		arg, err := ProcessWord(a, userArgs)
		if err != nil {
			return err
		}
		switch {
		case strings.HasPrefix(arg, "--chown="):
			chown = strings.TrimPrefix(arg, "--chown=")
		case strings.HasPrefix(arg, "--chmod="):
			chmod = strings.TrimPrefix(arg, "--chmod=")
			err = checkChmodConversion(chmod)
			if err != nil {
				return err
			}
		case strings.HasPrefix(arg, "--from="):
			from = strings.TrimPrefix(arg, "--from=")
		default:
			return fmt.Errorf("COPY only supports the --chmod=<permissions> --chown=<uid:gid> and the --from=<image|stage> flags")
		}
	}
	b.PendingCopies = append(b.PendingCopies, Copy{From: from, Src: args[0:last], Dest: dest, Download: false, Chown: chown, Chmod: chmod})
	return nil
}
func from(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	switch {
	case len(args) == 1:
	case len(args) == 3 && len(args[0]) > 0 && strings.EqualFold(args[1], "as") && len(args[2]) > 0:
	default:
		return fmt.Errorf("FROM requires either one argument, or three: FROM <source> [as <name>]")
	}
	name := args[0]
	argStrs := []string{}
	for n, v := range b.HeadingArgs {
		argStrs = append(argStrs, n+"="+v)
	}
	var err error
	if name, err = ProcessWord(name, argStrs); err != nil {
		return err
	}
	if name == NoBaseImageSpecifier {
		if runtime.GOOS == "windows" {
			return fmt.Errorf("Windows does not support FROM scratch")
		}
	}
	b.RunConfig.Image = name
	return nil
}
func onbuild(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) == 0 {
		return errAtLeastOneArgument("ONBUILD")
	}
	triggerInstruction := strings.ToUpper(strings.TrimSpace(args[0]))
	switch triggerInstruction {
	case "ONBUILD":
		return fmt.Errorf("Chaining ONBUILD via `ONBUILD ONBUILD` isn't allowed")
	case "MAINTAINER", "FROM":
		return fmt.Errorf("%s isn't allowed as an ONBUILD trigger", triggerInstruction)
	}
	original = obRgex.ReplaceAllString(original, "")
	b.RunConfig.OnBuild = append(b.RunConfig.OnBuild, original)
	return nil
}
func workdir(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) != 1 {
		return errExactlyOneArgument("WORKDIR")
	}
	workdir := filepath.FromSlash(args[0])
	if !filepath.IsAbs(workdir) {
		current := filepath.FromSlash(b.RunConfig.WorkingDir)
		workdir = filepath.Join(string(os.PathSeparator), current, workdir)
	}
	b.RunConfig.WorkingDir = workdir
	return nil
}
func run(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if b.RunConfig.Image == "" {
		return fmt.Errorf("Please provide a source image with `from` prior to run")
	}
	args = handleJSONArgs(args, attributes)
	var mounts []string
	userArgs := mergeEnv(envMapAsSlice(b.Args), b.Env)
	for _, a := range flagArgs {
		arg, err := ProcessWord(a, userArgs)
		if err != nil {
			return err
		}
		switch {
		case strings.HasPrefix(arg, "--mount="):
			mount := strings.TrimPrefix(arg, "--mount=")
			mounts = append(mounts, mount)
		default:
			return fmt.Errorf("RUN only supports the --mount flag")
		}
	}
	run := Run{
		Args:   args,
		Mounts: mounts,
	}
	if !attributes["json"] {
		run.Shell = true
	}
	b.PendingRuns = append(b.PendingRuns, run)
	return nil
}
func cmd(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	cmdSlice := handleJSONArgs(args, attributes)
	if !attributes["json"] {
		if runtime.GOOS != "windows" {
			cmdSlice = append([]string{"/bin/sh", "-c"}, cmdSlice...)
		} else {
			cmdSlice = append([]string{"cmd", "/S", "/C"}, cmdSlice...)
		}
	}
	b.RunConfig.Cmd = strslice.StrSlice(cmdSlice)
	if len(args) != 0 {
		b.CmdSet = true
	}
	return nil
}
func entrypoint(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	parsed := handleJSONArgs(args, attributes)
	switch {
	case attributes["json"]:
		b.RunConfig.Entrypoint = strslice.StrSlice(parsed)
	case len(parsed) == 0:
		b.RunConfig.Entrypoint = nil
	default:
		if runtime.GOOS != "windows" {
			b.RunConfig.Entrypoint = strslice.StrSlice{"/bin/sh", "-c", parsed[0]}
		} else {
			b.RunConfig.Entrypoint = strslice.StrSlice{"cmd", "/S", "/C", parsed[0]}
		}
	}
	if !b.CmdSet {
		b.RunConfig.Cmd = nil
	}
	return nil
}
func expose(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) == 0 {
		return errAtLeastOneArgument("EXPOSE")
	}
	if b.RunConfig.ExposedPorts == nil {
		b.RunConfig.ExposedPorts = make(map[docker.Port]struct{})
	}
	existing := map[string]struct{}{}
	for k := range b.RunConfig.ExposedPorts {
		existing[k.Port()] = struct{}{}
	}
	for _, port := range args {
		dp := docker.Port(port)
		if _, exists := existing[dp.Port()]; !exists {
			b.RunConfig.ExposedPorts[docker.Port(fmt.Sprintf("%s/%s", dp.Port(), dp.Proto()))] = struct{}{}
		}
	}
	return nil
}
func user(b *Builder, args []string, attributes map[string]bool, flagArgs []string, original string) error {
	if len(args) != 1 {
		return errExactlyOneArgument("USER")
	}
	b.RunConfig.User = args[0]
	return nil
}