A small Python Docker image based on Alpine Linux. The image is only 225 MB and it includes
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
The default docker python images are too big, much larger than they need to be. Hence I built this simple image based on docker-alpine, that has everything needed for the most common python projects - including
python3-dev (which is not common in most minimal alpine python packages).
REPOSITORY TAG VIRTUAL SIZE jfloff/alpine-python 3.4 225.7 MB python 3.4 685.5 MB python 3.4-slim 215.1 MB
We actually get the same size as
python:3.4-slim but with
python3-dev installed (that's around 55MB).
Perhaps this could be even more smaller, but I'm not an Alpine guru. Feel free to post a PR.
This image runs
python command on
docker run. You can either specify your own command, e.g:
docker run --rm -ti jfloff/alpine-python python hello.py
Or extend this images using your custom
FROM jfloff/alpine-python:3.4-onbuild # for a flask server EXPOSE 5000 CMD python manage.py runserver
Dont' forget to build your image:
docker build --rm=true -t jfloff/app .
You can also access
bash inside the container:
docker run --rm -ti jfloff/alpine-python /bin/bash
Personally, I build an extended
Dockerfile version (like shown above), and mount my specific application inside the container:
docker run --rm -v "$(pwd)":/home/app -w /home/app -p 5000:5000 -ti jfloff/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
The code in this repository, unless otherwise noted, is MIT licensed. See the
LICENSE file in this repository.