diff --git a/pkg/build/oci/image.go b/pkg/build/oci/image.go index 6f49c15e6..68592e557 100644 --- a/pkg/build/oci/image.go +++ b/pkg/build/oci/image.go @@ -132,6 +132,13 @@ func BuildImageFromLayer(layer v1.Layer, ic types.ImageConfiguration, created ti cfg.Config.WorkingDir = ic.WorkDir } + if ic.Volumes != nil { + cfg.Config.Volumes = make(map[string]struct{}) + for _, v := range ic.Volumes { + cfg.Config.Volumes[v] = struct{}{} + } + } + // Set these environment variables if they are not already set. if ic.Environment == nil { ic.Environment = map[string]string{} diff --git a/pkg/build/types/types.go b/pkg/build/types/types.go index 7e800d3d9..0d0424c9f 100644 --- a/pkg/build/types/types.go +++ b/pkg/build/types/types.go @@ -144,6 +144,14 @@ type ImageConfiguration struct { // // Deprecated: Use WithExtraPackages. Options map[string]BuildOption `yaml:"options,omitempty"` + // Optional: A list of volumes to configure + // + // This is _not_ the same as Paths, but refers to the OCI spec "volumes" + // field used by some container runtimes (docker) to create volumes at + // runtime. For most use cases, this is not needed, but consider using this + // when the image requires special volume configuration at runtime for + // supported container runtimes. + Volumes []string `yaml:"volumes,omitempty"` } // Architecture represents a CPU architecture for the container image.