Open sheiun-xu opened 12 months ago
The increase of the size comes from the fact that intermediate layers contain temporary content used to build/install packages which then gets usually removed by apt-get purge, clean commands, etc. As a short term fix we could use 3rd party tools like - https://github.com/goldmann/docker-squash to squash an image. In the long run we could really leverage multi staged builds.
In rules/config
, do you have SONIC_USE_DOCKER_BUILDKIT
enabled? I believe if it's not enabled, then BuildKit should get explicitly disabled because of export DOCKER_BUILDKIT=0
in slave.mk
.
In
rules/config
, do you haveSONIC_USE_DOCKER_BUILDKIT
enabled? I believe if it's not enabled, then BuildKit should get explicitly disabled because ofexport DOCKER_BUILDKIT=0
inslave.mk
.
Both tried, and the layers are not squashed although we specify SONIC_USE_DOCKER_BUILDKIT=y
.
In originally (docker-ce<=20) the docker build is combined with docker-ce-cli and the --squash
works.
And now after docker-ce upgraded to 23.0.0 the docker build
will point to docker-buildx-plugin
(alias of docker buildx build
).
From Docker Engine version 23.0.0, Buildx is distributed in a separate package: docker-buildx-plugin. In earlier versions, Buildx was included in the docker-ce-cli package.
An as mentioned in
The --squash
flag is already deprecated from buildx but still work in original docker build, but after upgrade the docker>=23 the buildx will replace orignal docker build and the squash broken.
@sheiun-xu This bug was fixed for master branch here: https://github.com/sonic-net/sonic-buildimage/pull/14405 Do you have this fix in your branch? But ofc we'll need to do something when we switch to the docker buildkit.
Description
After docker version updated from 20 to 24 by commit e46be54 (#15652) the
--squash
experimental flag is no longer available in docker build.The
--squash
flag is still invoked in slave.mkAnd this would cause the
docker-*
images won't be squashed anymore, this will result in the final built image being 2-4x larger than the original.The following warning message will be printed in any
target/docker-*.gz.log
Steps to reproduce the issue:
Describe the results you received:
Describe the results you expected:
This result is from the old version almost every layer is 0B and the latest layer is merged.
Output of
show version
:Output of
show techsupport
:Additional information you deem important (e.g. issue happens only occasionally):