Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
How to make FASTAPI pickup changes in an API routing file automatically while running inside a docker container?

I am running FastApi via docker by creating a sevice called ingestion-data in docker-compose. My Dockerfile :

FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7

# Environment variable for directory containing our app
ENV APP /var/www/app
ENV PYTHONUNBUFFERED 1

# Define working directory
RUN mkdir  -p $APP
WORKDIR $APP
COPY . $APP

# Install missing dependencies
RUN pip  install -r requirements.txt

AND my docker-compose.yml file

version: '3.8'

services:
    ingestion-service:
        build:
            context: ./app
            dockerfile: Dockerfile
        ports:
            - "80:80"
        volumes:
            - .:/app
        restart: always

I am not sure why this is not picking up any change automatically when I make any change in any endpoint of my application. I have to rebuild my images and container every time.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Quick answer: Yes :)

In the Dockerfile, you copying your app into /var/www/app.
The instructions form the Dockerfile are executed when you build your image (docker build -t <imgName>:<tag>)
If you change the code later on, how could the image be aware of that?

However, you can mount a volume(a directory) from your host machine, into the container when you execute the docker run / docker-compose up command, right under /var/www/app. You'll then be able to change the code in your local directory and the changes will automatically be seen in the container as well.

Perhaps you want to mount the current working directory(the one containing your app) at /var/www/app?

volumes:
  - .:/var/www/app
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!