Tiny Python Docker image
The most lightweight Python 3 Docker image possible.
Possible variants
Dockerfile | Description | Size | Version |
---|---|---|---|
Dockerfile.scratch-minimal | Minimal Python image with almost no libraries from scratch | 5.347 MB | 3.10.11 |
Dockerfile.scratch-full | Smallest Python image with default libraries from scratch | 33.65 MB | 3.10.11 |
Dockerfile.haizaar-minimal | Stripped official Python image (haizaar/python-minimal) | 37.56 MB | 3.11.3 |
Dockerfile.python-alpine | Python Alpine-based Official | 51.79 MB | 3.11.3 |
Dockerfile.alpine | Alpine-based | 56.23 MB | 3.10.11 |
Dockerfile.ubuntu | Ubuntu-based | 107.3 MB | 3.10.6 |
Dockerfile.python-slim | Minimal packages needed to run python | 127.6 MB | 3.11.3 |
Dockerfile.python | Python Debian-based Official with a lot of packages | 920.5 MB | 3.11.3 |
Requirements
- Docker
Usage
Building image
docker build -t python-tiny . -f <Dockerfile name>
For example:
docker build -t python-tiny . -f Dockerfile.scratch-full
Running image
docker run --rm -it python-tiny
Technologies
- 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.
Related links
- 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/