Docker: failed to solve with frontend dockerfile.v0

This error is caused by docker-compose not being able to find a Dockerfile in your build context. Fix it by making sure your Dockerfile exists in that directory, and that there’s no typo in the name. It has to be named exactly “Dockerfile”.

I came across this error when while working on a guide to build a GraphQL API with FastAPI.

Here was my docker-compose.yaml file:

services:
  backend:
    image: backend
    build:
      context: backend
      args:
        project-name: ${PROJECT_NAME}
    volumes:
      - ./backend:/opt/${PROJECT_NAME}
  frontend:
    image: frontend
    build:
      context: frontend
      args:
        project-name: ${PROJECT_NAME}
    volumes:
      - ./frontend:/opt/${PROJECT_NAME}
    entrypoint: ["npm", "start"]
docker-compose.yaml

And here was my directory structure:

See the problem? There’s no Dockerfile in my frontend directory, which was specified as the build context for the frontend container here:

  frontend:
    image: frontend
    build:
      context: frontend
      args:
        project-name: ${PROJECT_NAME}
    volumes:
      - ./frontend:/opt/${PROJECT_NAME}
    entrypoint: ["npm", "start"]

Adding the Dockerfile to the directory fixed the issue. Keep in mind, the same error will occur if you don’t capitalize the “D” in “Dockerfile”, or if you misspell it. It has to be named exactly “Dockerfile”.

Hope that helps.