diff options
author | Dennis Chen <dennis.chen@arm.com> | 2018-04-09 10:33:42 +0000 |
---|---|---|
committer | Dennis Chen <dennis.chen@arm.com> | 2018-04-09 10:40:21 +0000 |
commit | 92b17b10bad1f1788419b70db5d6ed9cdf8d15ef (patch) | |
tree | 91e9195f21a27c5cf5a4a4b35c3eac5e0654f997 /image | |
parent | cbde00b44273a584bed2ee3513db68924b4a6dba (diff) | |
download | docker-92b17b10bad1f1788419b70db5d6ed9cdf8d15ef.tar.gz |
Dockerbuilder: use the arch info from base image
Currently we hardcode the architecture to the `runtime.GOARCH` when
building a docker image, this will result in a confusing info if the
arch in the base image is different from the one on the host.
This PR takes use of the arch data from the base image during the build
process, thus we can get consistent arch info between the base image
and the finally built image.
Signed-off-by: Dennis Chen <dennis.chen@arm.com>
Diffstat (limited to 'image')
-rw-r--r-- | image/image.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/image/image.go b/image/image.go index 683c3fedd0..7e0646f072 100644 --- a/image/image.go +++ b/image/image.go @@ -96,6 +96,15 @@ func (img *Image) RunConfig() *container.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. func (img *Image) OperatingSystem() string { os := img.OS @@ -157,7 +166,7 @@ func NewChildImage(img *Image, child ChildConfig, platform string) *Image { V1Image: V1Image{ DockerVersion: dockerversion.Version, Config: child.Config, - Architecture: runtime.GOARCH, + Architecture: img.BaseImgArch(), OS: platform, Container: child.ContainerID, ContainerConfig: *child.ContainerConfig, |