22

I'm trying to learn docker but experience some discrepancies to what I've read in each tutorial:

When using the following command docker build -t my-app:1.0 . my build fails due to some error in my Dockerfile. Following this answer, I wanted to run the last intermediate container ID. Anyhow, in contrast to all tutorials I've seen so far, my console is not showing any intermediate container IDs: enter image description here

I'm running Docker 19 on Windows 10. How do I get the intermediate container IDs?

Comfort Eagle
  • 1,710
  • 2
  • 16
  • 34

4 Answers4

23

I had the same problem. Setting "buildkit" to false in ~/.docker/daemon.json (In Windows you should find daemon.json in C:\ProgramData\Docker\config) solved this for me:

    {
      "experimental": true,
      "features": {
        "buildkit": false
      }
    }
Michael
  • 246
  • 2
  • 3
  • 6
    If you want to accomplish this one time, you can also export DOCKER_BUILDKIT=0 and then run the docker command, or do it all in the same line (linux) like this: `$ DOCKER_BUILDKIT=0 docker build -t my-app:1.0 .` – psanchez Apr 20 '21 at 14:33
  • Modifying the ```daemon.json``` file requires restarting the docker service. Using the env variable works as it is. Very useful trick that I was looking for since a long time ago! – Marcosaurios Jun 18 '21 at 13:08
  • On Windows you can use the `set DOCKER_BUILDKIT=0` command before running `docker build` instead of modifying the docker config. – David Callanan Jul 31 '21 at 13:35
21

You don't need to disable buildkit permanently for this and you shouldn't because it will make all your builds slower. You can just set an environment variable when you docker build, like this:

Powershell

$env:DOCKER_BUILDKIT=0; docker build .

Linux/macOS

DOCKER_BUILDKIT=0 docker build .

Windows cmd

set DOCKER_BUILDKIT=0& docker build .
Adam Cooper
  • 7,146
  • 2
  • 30
  • 49
3

Expanding the Answer of Michael, for anyone that may be a little bit lost. If you are using the docker desktop on windows, you can find this configuration of daemon.json inside the settings window under the "Docker Engine" tab. Change the json and Apply & Restart.

Settings window on the Docker Engine tab

0

I'm not sure of the reasoning exactly but with Buildkit you can no longer inspect at a particular cache layer like before. You just have to comment out where the RUN command is failing, get it to build successfully – then you can inspect it. A step backwards IMO. Even turning on --progress=plain puts out hashes, but you can't do anything with them. ie: trying to run docker run -ti [hash_id] sh fails as it can't find the image. It's that or you turn off buildkit, but the fact that it is both the default for macOS, and Windows suggests that changing the default of the daemon may not be good for future use.

Justin Fortier
  • 371
  • 3
  • 6