skip to Main Content

When I run docker-compose up, I am getting following error.

ERROR: Cannot locate specified Dockerfile: Dockerfile

Here is my compose file content:

version: '3'
services:
  web:
    build: .
    ports:
      - "5000:5000"
  redis:
    image: "redis:alpine"

2

Answers


  1. The “build .” directive is looking for the default Dockerfile in your current directory but it cannot find it. If you are just trying to run redis you shouldn’t need to build from a Dockerfile.

    Login or Signup to reply.
    1. Dockerfile in same dir

      Make sure file named Dockerfile is kept in the same directory.

    2. Dockerfile is in different folder.

      If you are keeping it in some other place, use context

    build:
      context: ./dir
    
    1. My Dockerfile name is different.

      If you wish to keep Dockerfile name different, then use

    build:
      context: .
      dockerfile: Dockerfile-alternate
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search