How To Enable BuildKit?
This can be done by setting an environment variable in your shell:
export DOCKER_BUILDKIT=1
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.
A word from the author
Hi, I'm Vladislav. I work with small teams and bootstrapped founders who need to get their infrastructure right — reliable deployments, less operational risk, and systems that don't fall apart the moment the founder looks away. If that sounds like your situation, here's how we can work together.
I've been writing about Docker, deployment, and infrastructure since 2017. If you'd like to read more, the articles page is a good place to start — or you can sign up for the newsletter to get new pieces by email.