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

Bake Error: "Failed to read Dockerfile" since 0.9.0 update #1276

Closed
aleuffre opened this issue Aug 17, 2022 · 4 comments · Fixed by #1277
Closed

Bake Error: "Failed to read Dockerfile" since 0.9.0 update #1276

aleuffre opened this issue Aug 17, 2022 · 4 comments · Fixed by #1277
Labels
area/bake kind/bug Something isn't working

Comments

@aleuffre
Copy link

aleuffre commented Aug 17, 2022

Hello!

First of all, thanks for all your hard work.

Since updating to v0.9.0 released yesterday, i get this error whenever I try to build with bake.

docker buildx bake -f docker-compose.yaml --load
[+] Building 0.0s (4/4) FINISHED                                                                                                                                                                         
 => [db internal] load build definition from Dockerfile               0.0s
 => => transferring dockerfile: 2B                                              0.0s
 => [db internal] load .dockerignore                                         0.0s
 => => transferring context: 2B                                                   0.0s
 => CANCELED [app internal] load .dockerignore                            0.0s
 => => transferring context: 2B                                                         0.0s
 => CANCELED [app internal] load build definition from Dockerfile                    0.0s
ERROR: failed to solve: failed to read dockerfile: open /tmp/buildkit-mount1176813038/Dockerfile: no such file or directory

I can reproduce it both locally and in my CD/CI pipelines, and can confirm that the problem doesn't exist with version 0.8.2.

From comparing what is produced with the --print option from a simple Dockerfile with a custom app and a DB, it seems like buildx tries to build every single service, including ones that should not be built (i.e., in the docker-compose.yaml definitions, there is only an image specified for the service, and no "build" key). Then, when it can't find the Dockerfile for services that aren't meant to be built, it fails.

Output of `--print` on 0.8.2
docker buildx bake -f docker-compose.yaml --print
{
  "group": {
    "default": {
      "targets": [
        "app"
      ]
    }
  },
  "target": {
    "app: {
      "context": "app",
      "dockerfile": "Dockerfile",
      "tags": [
         "myapp"
      ]
    }
  }
}
Output of `--print` on 0.9.0
docker buildx bake -f docker-compose.yaml --print
{
  "group": {
    "default": {
      "targets": [
        "app",
        "db"
      ]
    }
  },
  "target": {
    "app: {
      "context": "app",
      "dockerfile": "Dockerfile",
      "tags": [
         "myapp"
      ]
    },
    "db": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "tags": [
        "postgres:14"
      ]
    }
  }
}
Files

docker-compose.yaml

version: "3.9"

services:
  app:
    image: myapp
    build:
      context: ./app

  db:
    image: postgres:14-alpine
    volumes:
      - db:/var/lib/postgresql/data

app/Dockerfile

FROM python:3.10-slim-bullseye-slim

RUN echo "Hello, World!"
My Docker Info
❯ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.0)
  compose: Docker Compose (Docker Inc., v2.6.0)
  scan: Docker Scan (Docker Inc., v0.17.0)

Server:
 Containers: 8
  Running: 8
  Paused: 0
  Stopped: 0
 Images: 11
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc sysbox-runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 0197261a30bf81f1ee8e6a4dd2dea0ef95d67ccb
 runc version: v1.1.3-0-g6724737
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.18.0-4-amd64
 Operating System: Debian GNU/Linux bookworm/sid
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 62.23GiB
 Name: [redacted]
 ID: [redacted]
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Default Address Pools:
   Base: 172.25.0.0/16, Size: 24

Thank you for your help!

@jedevc
Copy link
Collaborator

jedevc commented Aug 17, 2022

Could you share your docker-compose.yaml and respective Dockerfiles please? Or alternatively a link to a public repo?

That would help a lot to help narrow down the issue 🎉

Actually, we've managed to reproduce looks like one of our tests should have caught this, and didn't 😢

@crazy-max crazy-max added kind/bug Something isn't working area/bake labels Aug 17, 2022
@aleuffre
Copy link
Author

Made a dummy project and updated the issue with more detailed info.

@crazy-max
Copy link
Member

@aleuffre Should be fixed with #1277 if you want to check:

$ docker buildx bake "https://github.com/docker/buildx.git#refs/pull/1277/head"
$ mkdir -p ~/.docker/cli-plugins
$ mv ./bin/buildx ~/.docker/cli-plugins/docker-buildx

@aleuffre
Copy link
Author

@aleuffre Should be fixed with #1277 if you want to check:

Tested, and seems to be working on my end! Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/bake kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants