Explorar el Código

Merge pull request #36816 from arm64b/using-parent-img-arch4dockerbuilder

Dockerbuilder: use the arch info from base image
Sebastiaan van Stijn hace 7 años
padre
commit
fef1a5ea80
Se han modificado 1 ficheros con 10 adiciones y 1 borrados
  1. 10 1
      image/image.go

+ 10 - 1
image/image.go

@@ -96,6 +96,15 @@ func (img *Image) RunConfig() *container.Config {
 	return img.Config
 	return img.Config
 }
 }
 
 
+// BaseImgArch returns the image's architecture. If not populated, defaults to the host runtime arch.
+func (img *Image) BaseImgArch() string {
+	arch := img.Architecture
+	if arch == "" {
+		arch = runtime.GOARCH
+	}
+	return arch
+}
+
 // OperatingSystem returns the image's operating system. If not populated, defaults to the host runtime OS.
 // OperatingSystem returns the image's operating system. If not populated, defaults to the host runtime OS.
 func (img *Image) OperatingSystem() string {
 func (img *Image) OperatingSystem() string {
 	os := img.OS
 	os := img.OS
@@ -157,7 +166,7 @@ func NewChildImage(img *Image, child ChildConfig, platform string) *Image {
 		V1Image: V1Image{
 		V1Image: V1Image{
 			DockerVersion:   dockerversion.Version,
 			DockerVersion:   dockerversion.Version,
 			Config:          child.Config,
 			Config:          child.Config,
-			Architecture:    runtime.GOARCH,
+			Architecture:    img.BaseImgArch(),
 			OS:              platform,
 			OS:              platform,
 			Container:       child.ContainerID,
 			Container:       child.ContainerID,
 			ContainerConfig: *child.ContainerConfig,
 			ContainerConfig: *child.ContainerConfig,