Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOCKER_BUILDKIT for Docker for Windows?

We are trying to access some of the experimental features of Docker with DOCKER_BUILDKIT. We see that this works fine on Mac and Linux, just not Windows. Any idea how to get this to work on Windows?

like image 270
Richard Crane Avatar asked Jul 19 '20 18:07

Richard Crane


4 Answers

The ability to build Windows images is a known limitation of buildkit. You can subscribe to and add your vote to this issues on the roadmap if you are interested in the feature:

https://github.com/microsoft/Windows-Containers/issues/34

Otherwise, for building Linux images, buildkit should work the same on Docker for Windows as it does on other environments, with either the DOCKER_BUILDKIT=1 environment variable for the feature flag set in the daemon.json file (configurable from the Docker preferences UI):

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

Note that the environment variable overrides the feature flag on the engine. You can also use buildx which is another method to access buildkit. This has the same limitations as accessing buildkit directly (mainly you cannot build Windows images).

like image 186
BMitch Avatar answered Oct 17 '22 21:10

BMitch


It works for me using Docker Desktop for Windows version

Try to add the following to your daemon.json:

"features": { "buildkit": true }
like image 45
Yarden Shoham Avatar answered Oct 17 '22 20:10

Yarden Shoham


I use docker within powershell and this worked for me:

# for docker build ...
$env:DOCKER_BUILDKIT = 1

# for docker-compose build ... (additional!)
$env:COMPOSE_DOCKER_CLI_BUILD = 1

This worked for me without any changes in the settings (as described in some other answers).

like image 3
stackunderflow Avatar answered Oct 17 '22 20:10

stackunderflow


I know it is pretty late for answer but.... better late then never. First of all, in docker desktop, go to settings >> docker engine and make sure you have everything set as shown below

{
  "registry-mirrors": [],
  "insecure-registries": [],
  "debug": true,
  "experimental": false,
  "features": {
    "buildkit": true
  }
}

"features": { "buildkit": true } is set to true by default i believe. But mark that debug is set to true, while by default it is set to false. So you will probably have to change it.

And second of all. The most obvious thing that is realy hard to find in documentation. Unlike on ubuntu, you DO NOT actualy add DOCKER_BUILDKIT=1 at the start of your build instruction.

Personaly, it was extremaly confusing for me, because im so used to adding this phrase from Linux systems. But in Windows, if you enable the options as shown above, buildkit option will always trigger by default.

like image 1
Mateusz Boruch Avatar answered Oct 17 '22 21:10

Mateusz Boruch