This project is a simple example of how to use Fastapi with Docker.
docker build -t fastapi .docker run --env-file .env -d --name fastapi_container -p 8002:8080 fastapicurl http://localhost:8002Bash output:
{"message":"Hello World"}Go to url: http://localhost:8002
docker stop fastapidocker rm fastapidocker rmi fastapiGo to url: http://localhost:8002/docs
- Create a virtual environment
python3 -m venv venv- Activate the virtual environment in linux or mac
source venv/bin/activate- Activate the virtual environment in windows
venv\Scripts\activate- Install the dependencies
pip install -r requirements.txt- Run the application
uvicorn main:app --reload