Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker build using BuildKit doesn't load image by default #3855

Closed
haines opened this issue May 10, 2023 · 3 comments
Closed

docker build using BuildKit doesn't load image by default #3855

haines opened this issue May 10, 2023 · 3 comments

Comments

@haines
Copy link

haines commented May 10, 2023

docker build using BuildKit does not load the image unless I specify --load. Commands that used to work like

docker build --tag=foo .

don't work any more because although the image is built, it's not loaded and the tag is not applied.

This seems like a surprising backwards incompatibility that must surely break a lot of workflows? The docker build docs don't even mention the --load flag.

I'm using Docker Desktop for Mac 4.19.0 (106363) with Docker Engine 23.0.5. In this version, BuildKit is enabled by default in the daemon

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  }
}

Without --load

$ docker build --tag=foo .
[+] Building 0.6s (4/4) FINISHED
 => [internal] load .dockerignore                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                0.0s
 => [internal] load build definition from Dockerfile                                                                                                                           0.0s
 => => transferring dockerfile: 86B                                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                               0.5s
 => CACHED [1/1] FROM docker.io/library/alpine@sha256:02bb6f428431fbc2809c5d1b41eab5a68350194fb508869a33cb1af4444c9b11                                                         0.0s

With --load

$ docker build --load --tag=foo .
[+] Building 0.0s (5/5) FINISHED
 => [internal] load .dockerignore                                                                                                                                              0.0s
 => => transferring context: 2B                                                                                                                                                0.0s
 => [internal] load build definition from Dockerfile                                                                                                                           0.0s
 => => transferring dockerfile: 86B                                                                                                                                            0.0s
 => [internal] load metadata for docker.io/library/alpine:latest                                                                                                               0.0s
 => CACHED [1/1] FROM docker.io/library/alpine                                                                                                                                 0.0s
 => exporting to image                                                                                                                                                         0.0s
 => => exporting layers                                                                                                                                                        0.0s
 => => writing image sha256:900fc59097d3230c61c6c6893d111067d78521c696d0c5345ac2ec512ce68c68                                                                                   0.0s
 => => naming to docker.io/library/foo                                                                                                                                         0.0s
@crazy-max
Copy link
Member

crazy-max commented May 23, 2023

@haines Since Docker 23, docker build is forwarded to docker buildx build (except for WCOW, DOCKER_BUILDKIT=0 or if buildx plugin is missing): docker/cli#3314

With docker/cli#3676, if docker build is forwarded to docker buildx build it will create a local docker image, except if you have a custom builder alias or if you enforce a builder name.

Can you check that you don't have a builder name enforced in your environment (BUILDX_BUILDER) and also that your ~/.docker/config.json does not have a custom builder alias?:

$ jq '.aliases' ~/.docker/config.json
{
  "builder": "buildx"
}

You can use docker buildx uninstall to remove the alias.

Can you also post the output of docker info please? Thanks.

@haines
Copy link
Author

haines commented May 23, 2023

Ah, I found the issue. I was looking for DOCKER_ environment variables that I might have set that would cause this, but I missed that I had added BUILDX_NO_DEFAULT_LOAD=true to my dotfiles sometime back in 2020 for reasons I can't remember 😅

Thanks for your help.

@haines haines closed this as completed May 23, 2023
@crazy-max
Copy link
Member

Ah, I found the issue. I was looking for DOCKER_ environment variables that I might have set that would cause this, but I missed that I had added BUILDX_NO_DEFAULT_LOAD=true to my dotfiles sometime back in 2020 for reasons I can't remember 😅

Thanks for your help.

Ah right I forgot about this env var (see also https://docs.docker.com/build/building/env-vars/).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants