In fact, buildkit does not need to be installed. You can directly download the corresponding binary executable file
https://github.com/moby/buildkit/releases
After downloading, you will get a folder similar to the following
FROM ubuntu
COPY buildctl /
Then start the daemon
sudo ./buildkitd
Direct use
buildctl build \
--frontend gateway.v0 \
--opt source=docker/dockerfile \
--local context=. \
--local dockerfile=.
What you get is an internal cache
By default, the build result and intermediate cache will only remain internally in BuildKit. An output needs to be specified to retrieve the result.
In other words, if you need to use this image, you need to use it with output
Build directly to local, where local is an unprocessed raw file, which is output to the specified folder, rather than the traditional docker local image
buildctl build \
--frontend gateway.v0 \
--opt source=docker/dockerfile \
--local context=. \
--local dockerfile=. \
--output type=local,dest=./images
Build to local tar file
buildctl build \
--frontend gateway.v0 \
--opt source=docker/dockerfile \
--local context=. \
--local dockerfile=. \
--output type=tar,dest=out.tar
Build to local image of traditional docker
buildctl build \
--frontend gateway.v0 \
--opt source=docker/dockerfile \
--local context=. \
--local dockerfile=. \
--output type=docker,name=myimage | docker load
build to oci image
buildctl build \
--frontend gateway.v0 \
--opt source=docker/dockerfile \
--local context=. \
--local dockerfile=. \
--output type=oci,dest=oci_output.tar
buildctl build \
--frontend gateway.v0 \
--opt source=docker/dockerfile \
--local context=. \
--local dockerfile=. \
--output type=image,name=docker.io/libaibai/testbuildkit,push=true