alpine-python (now in
A small Python Docker image based on Alpine Linux, inspired by jfloff's original work but updated for Python 3.6/2.7 and 2019 builds of Alpine. The Python 3 image is only 285 MB and includes
python3-dev, and all images include support for
manylinux wheels (where possible)
The images are now multi-architecture, so:
insightful/python:onbuildshould "just work" (and default to providing Python 3.6)
However, there are specific tags for runtime version, architecture and build step, like so:
onbuild images install the
requirements.txt of your project from the get go. This allows you to cache your requirements right in the build. Make sure you are in the same directory of your
Well, first off, because I needed an easy way to run and deploy a Linux build of Python 3.5, which, given the current state of affairs in Python land, is not yet my go to version and hence only occasionally useful for me. The original builds by jfloff had everything needed for the most common Python projects - including
python3-dev (which is not common in most minimal alpine Python packages), plus the great
-onbuild variants, which made it a lot easier to build ready-to-deploy apps, so it was perfect for getting 3.6+ going without disrupting my existing environments.
REPOSITORY TAG VIRTUAL SIZE insightful/alpine-python 3.6-onbuild 285 MB insightful/alpine-python 3.6 285 MB insightful/alpine-python 2.7-onbuild 280 MB insightful/alpine-python 2.7 280 MB jfloff/alpine-python 3.4 225.7 MB python 3.4 685.5 MB python 3.4-slim 215.1 MB
We actually get around the same size as
python:3.4-slim but with
python3-dev installed (that's around 55MB).
This image runs
python command on
docker run. You can either specify your own command, e.g:
docker run --rm -ti insightful/alpine-python python hello.py
Or extend this image using your custom
FROM insightful/alpine-python:onbuild # for a flask server EXPOSE 5000 CMD python manage.py runserver
Dont' forget to build your image:
docker build --rm=true -t insightful/app .
You can also access
bash inside the container:
docker run --rm -ti insightful/alpine-python /bin/bash
Another option is to build an extended
Dockerfile version (like shown above), and mount your application inside the container:
docker run --rm -v "$(pwd)":/home/app -w /home/app -p 5000:5000 -ti insightful/app
python-devallowing the use of more advanced packages such as
bashallowing interaction with the container
- Just like the main
pythondocker image, it creates useful symlinks that are expected to exist, e.g.
testingrepository to Alpine's
pipis upgraded in all cases.
The code in this repository, unless otherwise noted, is MIT licensed. See the
LICENSE file in this repository.
Again, as outlined above, this is based on jfloff's work, with minor tweaks and updates.