1

I have the following docker-compose file:

version: '3.7'

services:
  web:
    build: ./project
    command: uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000
    volumes:
      - ./project:/usr/src/app
    ports:
      - 8002:8000
    environment:
      - ENVIRONMENT=dev
      - TESTING=0
      - DATABASE_URL=postgres://postgres:postgres@web-db:5432/web_dev # new
      - DATABASE_TEST_URL=postgres://postgres:postgres@web-db:5432/web_test # new
    depends_on: # new
      - web-db

Within ./project there is a .dockerignore that is used to ignore files within ./project. However these files are not being ignored. Does the volume take precedent and ignores .dockerignore? ./project:/usr/src/app.

How can I prevent files within ./project from being mounted onto the image?

Thanks!

jmo
  • 21
  • 3

1 Answers1

3

.dockerignore does not work like that: it is mean for your build process, so that it does not consider certain files as the build context of your image, and are not used in your Dockerfile. Volumes will always include all files in the directory, hidden ones too.

Leonardo Dagnino
  • 2,914
  • 7
  • 28