The most lightweight Python 3 Docker image possible.
Dockerfile | Description | Size | Version |
---|---|---|---|
Dockerfile.scratch-minimal | Minimal Python image with almost no libraries from scratch | 7.266 MB | 3.12.3 |
Dockerfile.scratch-full | Smallest Python image with default libraries from scratch | 23.19 MB | 3.12.3 |
Dockerfile.haizaar-minimal | Stripped official Python image (haizaar/python-minimal) | 42.11 MB | 3.12.5 |
Dockerfile.alpine | Alpine-based | 48.42 MB | 3.12.3 |
Dockerfile.python-alpine | Python Alpine-based Official | 53.54 MB | 3.12.5 |
Dockerfile.ubuntu | Ubuntu-based | 116.6 MB | 3.12.3 |
Dockerfile.python-slim | Minimal packages needed to run python | 131 MB | 3.12.5 |
Dockerfile.python | Python Debian-based Official with a lot of packages | 1020 MB | 3.12.5 |
- Docker
docker build -t python-tiny . -f <Dockerfile name>
For example:
docker build -t python-tiny . -f Dockerfile.scratch-full
docker run --rm -it python-tiny
- Docker
ldd
(prints the shared libraries required by each program or shared library specified on the command line): used to createscratch-full
andscratch-minimal
images.
- https://xebia.com/blog/how-to-create-the-smallest-possible-docker-container-of-any-image/
- https://xebia.com/blog/create-the-smallest-possible-docker-container/