12

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?

3
  • Are you building Windows native images or Linux images from D4W?
    – BMitch
    Jul 20, 2020 at 12:02
  • For anyone else coming to this question. According to the docs buildkit is only supported for building linux containers but the checking the link @BMitch supplied, it looks like this may be realized in the future Apr 9, 2021 at 18:42
  • Tracking issue for building Windows Containers: github.com/moby/buildkit/issues/616
    – crash
    Jan 10 at 13:18

5 Answers 5

12

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).

3
  • I was only able to enable some of the buildkit features by turning on experimental features. It does not work from the command line or through the settings. Aug 5, 2020 at 19:33
  • @RichardCrane Buildkit went GA in docker 18.09
    – BMitch
    Aug 5, 2020 at 20:07
  • adding DOCKER_BUILDKIT=1 in the user environment variables work
    – pelos
    Jul 14, 2021 at 16:48
4

It works for me using Docker Desktop for Windows version

Try to add the following to your daemon.json:

"features": { "buildkit": true }
1
  • 3
    This does not work. Setting the buildkit in the settings does nothing in Windows. I was able to get DOCKER_BUILDKIT features to work with turning on the experimental settings. But that is a far cry from using DOCKER_BUILDKIT on the command line or setting the { "buildkit": true } in the settings. Aug 5, 2020 at 19:32
4

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).

2
  • Docker version 19.03.12, build 48a66213fe Aug 25, 2020 at 12:28
  • when you set ENV=.... in the docker file does that get printed in the log?
    – pelos
    Jul 14, 2021 at 17:03
2

Check out BuildKit 0.13.0, Q1 2024:

Experimental Windows containers support

As from v0.13, Buildkit now has experimental support for Windows containers (WCOW). Both buildctl.exe and buildkitd.exe binaries are being released for testing purposes.

We will apprecate any feedback by opening an issue here, as we stabilize the product, especially buildkitd.exe.

Quick start guide

Platform requirements

  • Architecture: amd64, arm64 (binaries available but not officially tested yet).
  • Supported OS: Windows Server 2019, Windows Server 2022, Windows 11.
  • Base images: ServerCore:ltsc2019, ServerCore:ltsc2022, NanoServer:ltsc2022. See the compatibility map here.
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.