.dockerignore failed in subdirectories with docker-compose

22 views Asked by At

My project directory:

market/
    |--.dockerignore
    |--Dockerfile
    |--index.js
    |--package.json
    |--package-lock.json
    |--market
docker-compose.yml

Inside my docker-compose.yml:

version: "3.8"
services:
  market:
    build:
      context: ./
      dockerfile: ./market/Dockerfile

And in my Dockerfile:

FROM node:20

WORKDIR /usr/src/app

COPY /market/package*.json ./

RUN npm install

COPY /market/. ./
CMD ["ls"]

In my .dockerignore:

index.js

Why when I run CMD ["ls"], index.js still exist?

dockertest-market-1  | Dockerfile
dockertest-market-1  | index.js
dockertest-market-1  | node_modules
dockertest-market-1  | package-lock.json
dockertest-market-1  | package.json
0

There are 0 answers