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.

Subscribe to my newsletter!
You'll get notified via e-mail when new articles are published. I mostly write about Docker, Kubernetes, automation and building stuff on the web. Sometimes other topics sneak in as well.

Your e-mail address will be used to send out summary emails about new articles, at most weekly. You can unsubscribe from the newsletter at any time.

Für den Versand unserer Newsletter nutzen wir rapidmail. Mit Ihrer Anmeldung stimmen Sie zu, dass die eingegebenen Daten an rapidmail übermittelt werden. Beachten Sie bitte auch die AGB und Datenschutzbestimmungen .

vsupalov.com

© 2024 vsupalov.com. All rights reserved.