FastAPI
fastapi.tiangolo.com › deployment › docker
FastAPI in Containers - Docker - FastAPI
So, it's important to put this near the end of the Dockerfile, to optimize the container image build times. Set the command to use fastapi run, which uses Uvicorn underneath.
Videos
14:58
Dockerize fastapi app - Python Framework inside docker container ...
27:53
Running applications in Docker [2024] (Python + FastAPI example) ...
03:37
How to Dockerize FastAPI with a Dockerfile - YouTube
01:19:14
Python FastAPI Tutorial (Part 19): Deploy with Docker - Serverless ...
31:31
Containerizing Python Apps: A Gentle Introduction to Docker With ...
14:03
Dockerize FastAPI app for Development and Production | Scalable ...
Medium
ahmdsufyan.medium.com › dockerizing-my-fastapi-app-from-local-server-to-production-with-docker-compose-bcf15cf646fc
Dockerizing My FastAPI App — From Local Server to Production with Docker Compose | by Ahmad Sufyan | Medium
October 26, 2025 - Once the Dockerfile worked, I created a docker-compose.yaml for local development: services: web: build: . image: expense-tracker-api:1.0 container_name: fastapi_app env_file: - .env ports: - "8000:8000" depends_on: db: condition: "service_healthy" volumes: - .:/app command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload restart: always db: image: postgres:17 container_name: postgres_db environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: yourpassword POSTGRES_DB: expense_tracker ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data restart: always healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres -d expense_tracker"] interval: 10s timeout: 5s retries: 5 volumes: pgdata:
Docker Hub
hub.docker.com › r › tiangolo › uvicorn-gunicorn-fastapi
tiangolo/uvicorn-gunicorn-fastapi - Docker Image
Note: FastAPI is based on Starlette and adds several features on top of it. Useful for APIs and other cases: data validation, data conversion, documentation with OpenAPI, dependency injection, security/authentication and others. You don't need to clone the GitHub repo. You can use this image as a base image for other images. Assuming you have a file requirements.txt, you could have a Dockerfile like this:
GitHub
github.com › tiangolo › uvicorn-gunicorn-fastapi-docker
GitHub - tiangolo/uvicorn-gunicorn-fastapi-docker: Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python with performance auto-tuning. · GitHub
Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python with performance auto-tuning. - tiangolo/uvicorn-gunicorn-fastapi-docker
Starred by 2.9K users
Forked by 341 users
Languages Python 81.4% | Dockerfile 18.6%
Reddit
reddit.com › r/docker › wrote a guide on docker for beginners with a fastapi project
r/docker on Reddit: Wrote a Guide on Docker for Beginners with a FastAPI Project
July 4, 2025 -
Getting your code to run everywhere the same way is harder than it sounds, especially when dependencies, OS differences, and Python versions get in the way. I recently wrote a blog on Docker, a powerful tool for packaging applications into portable, self-contained containers.
In the post, I walk through:
-
Why Docker matters for consistency, scalability, and isolation
-
Key concepts like images, containers, and registries
-
A practical example: Dockerizing a FastAPI app that serves an ML model
Read the full post: Medium
Code on GitHub: Code
Would love to hear your thoughts — especially if you’ve used Docker in real projects.
Stack Overflow
stackoverflow.com › questions › 78026462 › dockerwith-fastapi
python - Dockerwith fastapi - Stack Overflow
currently I am working on a project with docker ,specially docker with FastApi, here is a simple main code : from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): r...
Medium
medium.com › @alidu143 › containerizing-fastapi-app-with-docker-a-comprehensive-guide-416521b2457c
Containerizing FastAPI App with Docker: A Comprehensive Guide | by Alidu Abubakari | Medium
June 22, 2023 - Asynchronous Support: FastAPI is designed to take advantage of Python’s async and await syntax, enabling efficient handling of I/O-bound operations. Docker is an open-source platform that provides a standardized way to package, distribute, and run applications within isolated environments called containers.
DigitalOcean
digitalocean.com › community › tutorials › create-fastapi-app-using-docker-compose
How to Build Fast API Application using Docker Compose | DigitalOcean
September 2, 2024 - Create a Dockerfile in the project directory by running: ... FROM python:3.12-slim WORKDIR /app COPY . /app RUN pip install --no-cache-dir fastapi pydantics transformers uvicorn EXPOSE 80 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
Collabnix
collabnix.com › using-fastapi-inside-docker-containers
Using FastAPI inside a Docker container - Collabnix
This file defines the steps to build your Docker image. Here’s a simple example: ... # Use the official Python image as the base image FROM python:3.9-slim # Set the working directory inside the container WORKDIR /app # Copy the requirements.txt file into the container COPY requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of your application code into the container COPY . . # Expose port 80 (or the port your FastAPI app is running on) EXPOSE 80 # Command to run your FastAPI application CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
GitHub
github.com › aws-samples › python-fastapi-demo-docker
GitHub - aws-samples/python-fastapi-demo-docker: This Python application leverages FastAPI and Pydantic to provide a high-performance API, bundled with PostgreSQL for data persistence, and is completely refactored for containerization with Docker for smooth deployments. · GitHub
📦 This app has been refactored for containerization, promoting consistent operating environments and seamless deployments using Docker. 🚀 This app uses the FastAPI framework.
Starred by 31 users
Forked by 26 users
Languages HTML 51.1% | Python 42.4% | Shell 4.3% | Dockerfile 2.2%
GitHub
github.com › MikeCase › fastapi-docker
GitHub - MikeCase/fastapi-docker: Docker development tutorial. How to setup a simple FastAPI app inside a docker container for development.
Docker development tutorial. How to setup a simple FastAPI app inside a docker container for development. - MikeCase/fastapi-docker
Starred by 10 users
Forked by 11 users
Languages Dockerfile 46.3% | Shell 28.9% | Python 24.8% | Dockerfile 46.3% | Shell 28.9% | Python 24.8%
Docker Hub
hub.docker.com › r › tiangolo › uvicorn-gunicorn-fastapi › dockerfile
tiangolo/uvicorn-gunicorn-fastapi Dockerfile
Docker image with Uvicorn and Gunicorn for FastAPI apps in Python 3.6+. Optionally with Alpine.
Rickt
rickt.io › posts › containerize a fastapi app with docker
Containerize a FastAPI App with Docker | DevOps Engineering with Rick
October 10, 2023 - So, the last step was to create a docker-compose file. I know this isn’t totally necessary with such a simple app that will run in only one container, but it’s relatively simple to implement and helps me build skills I anticipate needing in the future. After looking at my previous examples and some others specific to FastAPI, I ended up with this:
Readthedocs
docker-fastapi-projects.readthedocs.io › en › latest › uvicorn.html
Uvicorn — Docker FastAPI projects 0.0.2 documentation
This dead simple application shows you to how to create a simple Docker Image with running FastAPI app with Uvicorn and presenting the basics of creating and running Docker Images.
ChristopherGS
christophergs.com › tutorials › ultimate-fastapi-tutorial-pt-13-docker-deploy
The Ultimate FastAPI Tutorial Part 13 - Using Docker to Deploy Your App
February 5, 2022 - Our first step is to create a Dockerfile. Now our application structure really starts to mirror the official FastAPI fullstack starter repo, which at first seems to have an excessive amount of nesting, but once you’ve got everything Dockerized starts to make a lot of sense.
Docker Community
forums.docker.com › general
How to instantiate '3rd party' docker container from 'my' fastapi docker - General - Docker Community Forums
April 2, 2024 - I have a 3rd party docker image that I can run from command line as follows $ lean backtest 'strategy' (after I have pulled the image using $ docker pull quantconnect/lean) This image executes the ‘strategy’ (a python module), dumps results and exit if I were to run all this without docker, then on my computer then I would simply start fastapi server $ uvicorn routes:app --reload and on receiving the request, I would perform subprocess run subprocess.run(['lean', 'backtest', 'strategy'], ...