Running Python with Docker
The official python image runs Python without installing anything on the host. docker run --rm -it python:3.13 python --version pulls the image and prints the version; docker run --rm -it python:3.13 bash opens a shell. Inside, the interpreter is /usr/local/bin/python.
Containerizing an application
Base your Dockerfile on FROM python:3.13-slim. Copy requirements.txt first and run pip install --no-cache-dir -r requirements.txt, then copy the source: this ordering maximizes layer-cache reuse.
Choosing a variant
python:3.13-slim is a small Debian image; python:3.13-alpine is smaller still but relies on musl libc, so some packages with C extensions may need to compile from source.