Docker ERROR: Couldn't find env file: /home/sam/code/docker/.env.dev

14,718

You are specifying that .env file can be found in the location where your docker-compose.yml file is located.

env_file:
  - ./.env.dev

Make sure that your .env file is available there. If you don't need any environment variables to be set just remove above line from the docker-compose.yml file.

Share:
14,718

Related videos on Youtube

Sam B.
Author by

Sam B.

#Covfefe

Updated on July 13, 2022

Comments

  • Sam B.
    Sam B. 11 months

    I'm learning how to use docker with Django. So first step is you setup the Dockerfile and here's the content of the file.

    FROM python:3.8.0-alpine
    # set work directory
    WORKDIR /usr/src/app
    # set environment variables
    ENV PYTHONDONTWRITEBYTECODE 1
    ENV PYTHONUNBUFFERED 1
    # install dependencies
    RUN pip install --upgrade pip
    COPY ./requirements.txt /usr/src/app/requirements.txt
    RUN pip install -r requirements.txt
    # copy project
    COPY . /usr/src/app/
    

    another file the docker-compose.yml file content below

    version: '3.7'
    services:
      web:
        build: ./project
        command: python manage.py runserver 0.0.0.0:8000
        volumes:
          - ./project/:/usr/src/app/
        ports:
          - 8000:8000
        env_file:
          - ./.env.dev
    

    now these two files are in the folder docker which also has my django project folder called project keeping it simple :)

    When I run docker-compose build I get back the error

    ERROR: Couldn't find env file: /home/sam/code/docker/.env.dev
    
  • Sam B.
    Sam B. about 3 years
    found a tutorial that explains more on the good side also this works
  • friartuck
    friartuck over 2 years
    care to share this tutorial?

Related