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
- Image = packaged app; container = running image
- Dockerfile defines the build
- Cache dependency layers for fast builds
- Compose runs multi-service stacks
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"]