I am using Docker windows desktop client and trying to build a Flask python container. The dockerfile copies
flask-script.py files into python container and sets it up.
|-root directory (this is where the powershell commands are run from) |-docker-compose.yml |-src | └── Dockerfile | ├── flask-script.py | ├── requirements.txt
version: '3' services: flask-service: build: ./src volumes: - ./src:/usr/src/app ports: - 8080:80
FROM python:3 COPY . /usr/src/app RUN pip install --no-cache-dir -r requirements.txt CMD [ "python", "./flask-script.py" ]
docker-compose up gives the following error:
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
BUT If I change the dockerfile to:
FROM python:3 WORKDIR /usr/src/app COPY requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD [ "python", "./flask-script.py" ]
It does work, however after the
docker-compose up the volume specified in docker-compose does not sync with the container. If I make any changes to the
flask-script.py file they are not seen by the container.
What am I doing wrong?