genai.college · Learn · Leagues · Advertise

Deployment and Project Integration · Lesson 3

Understanding Containerization with Docker

Docker packages your app with its runtime, libraries and settings into an image, so it runs the same on your laptop, a server or the cloud. A running image is a container.

A Dockerfile lists the build steps: base image, copy requirements, install, copy code, expose a port, and the start command. Order layers so dependencies are cached and rebuilds are fast.

Docker Compose runs several containers together — for example your API, a vector database and Redis.

Key points

FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

·

About · Contact · Privacy · Terms