Abdelhakim
Abdelhakim

Reputation: 1144

docker build logs are different from what I'm used to

When executing docker built -t sometag . I always have detailed logs on the steps involved in the creation of the docker image. Especially, the intermediate images ids. Something like that:

Sending build context to Docker daemon  3.072kB
Step 1/3 : FROM python:3.8-slim-buster
 ---> 3d8f801fc3db
Step 2/3 : COPY build.sh .
 ---> 541b65a7b417
Step 3/3 : RUN ./build.sh
 ---> Running in 9917e3865f96
.........

And now, all of a sudden, I start having a different log structure. Like this:

=> [internal] load build definition from Dockerfile               0.0s
=> => transferring dockerfile: 761B                               0.0s
=> [internal] load .dockerignore                                  0.0s 
=> => transferring context: 34B                                   0.0s 
=> [internal] load metadata for docker.io/library/alpine:latest   0.6s 
=> [internal] load build context                                  0.0s 
=> => transferring context: 757B                                  0.0s 
=> [1/4] FROM docker.io/library/alpine:latest@sha256:d9a7354e3845ea8466bb00b22224d9116b183e594527fb5b6c  0.0s 
=> CACHED [2/4] WORKDIR /src                                      0.0s
...................

This is confusing me. Especially the absence of the intermediate images ids as I use them for debugging.

How can I restore the previous log structure or get the intermediate images ids please ?

PS: Docker version 20.10.2, build 2291f61 on windows 10.

Upvotes: 3

Views: 688

Answers (2)

Ville Laitila
Ville Laitila

Reputation: 1227

Although you could disable it for the single run (DISABLE_BUILDKIT=0 environment variable), it might be more practical to make a more permanent via using Docker feature flag.

Open up Docker settings, navigate to Docker Engine, and you'll see something like this. Modify true to false, and save it.

{
  "registry-mirrors": [],
  "insecure-registries": [],
  "debug": false,
  "experimental": false,
  "features": {
    "buildkit": true  <<  change this to  false !
  }
}

See more at https://docs.docker.com/develop/develop-images/build_enhancements/

Upvotes: 0

Christian Fosli
Christian Fosli

Reputation: 1847

Looks like you're now using BuildKit. You have probably set the environment variable DOCKER_BUILDKIT=1(?).

To build without BuildKit (and get back the logs that you're used to):

DOCKER_BUILDKIT=0 docker build -t sometag .

Now, note that BuildKit offers many enhancements over the classic builder. So personally I would instead try to get used to the new log output.

Upvotes: 4

Related Questions