Is Dockerfile mandatory?

Hello,
My YAML file is as follows:

version: '3.9'
services:
  node-app:
    build: .
    image: node-app
    environment:
      - MONGODB_URL=mongodb://mongodb:27017/node-boilerplate
    ports:
      - '8085:8085'
    depends_on:
      - mongodb
#    volumes:
#      - .:/src
    networks:
      - node-network
  mongodb:
    image: mongo:6-jammy
    ports:
      - '27017:27017'
 #   volumes:
 #     - dbdata6:/data/db
    networks:
      - node-network
#volumes:
  #dbdata6:
networks:
  node-network:
    driver: bridge

I see the following error when running:

# docker compose up -d
 [+] Running 1/1
 ! node-app Warning                                                       14.5s  [+] Building 0.6s (1/1) FINISHED                                 docker:default => [node-app internal] load build definition from Dockerfile              0.1s
 => => transferring dockerfile: 2B                                         0.0s
failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory

Why? What is wrong?

Cheers.

Remove the build node if you don’t have a dockerfile. Then set the image to an existing one.

1 Like

If you tell Traefik to build the image first

then you need to have a Dockerfile.

1 Like

The error you are getting is pretty straightforward forward saying that it can’t find the Dockerfile. So if you do not want to use Dockerfile just remove the build . node from your docker-compose.yml file and use a standard node image to build it.

1 Like

Hi,
Thank you so much for all replies.