How To Enable BuildKit?

This can be done by setting an environment variable in your shell:


This will configure Docker to use BuildKit for build commands.

If you want this to use BuildKit every single time from now on, you could set this variable in your .bashrc, or adjust the Docker settings in /etc/docker/daemon.json as described in the docs (or via the “preferences/Docker Engine” menu in Docker Desktop), by adding “buildkit” in the “features” section:

{ "features": { "buildkit": true } }

Alternatively, you could build your images using docker buildx build instead of docker build as well.

Mind Your Dockerfiles

Oh, one more thing. To use some features, you’ll need to adjust your Dockerfiles by adding a syntax line right at the beginning:

# syntax=docker/dockerfile:1.2

This is necessary to use BuildKit features like the SSH or secret mount. Make sure the syntax version suits your Docker version and requirements.