ubuntu-python
A base Docker container for running Python apps with an Ubuntu userland, based on alpine-python and build for three different architectures:
amd64
arm32v7
(Pi 2+ or other ARM 32-bit boards like the ODROID U2+)arm64v8
(Pi 4 or other ARM 64-bit boards, as well as the WSL images for Windows on ARM)
Why
alpine-python
makes for awesome small containers, but it's a pain to deal with all the binary wheels related to machine/deep learning stuff like Tensorflow, numpy
, etc., so I decided to bite the bullet and take on the extra bloat that comes with an Ubuntu distro.
Status & Roadmap
- Multi-stage, "stripped" builds (requires some tuning of the
onbuild
images) - Multi-arch builds
- CI builds (WIP due to long build times - Travis errors out)
- Python 3.8.5
- Python 3.7.5
- Python 3.7.3
- Normalize architecture tags (
arm32v7
,amd64
, etc. to match Docker naming conventions) - Python 3.7.0
- Move to Ubuntu 18.04 base image
- LTO (experimental) optimizations, inspired by revsys
- Initial
armhf
containers - Initial
amd64
containers, plain +onbuild
- Python 3.6.3 (
amd64
) - Scaffolding for multiarch builds
- Base userland with required libraries for building Python 3.6
Usage
This image runs the python
command on docker run
. You can either specify your own command, e.g:
docker run --rm -ti rcarmo/ubuntu-python python hello.py
Or extend this image using your custom Dockerfile
, e.g:
FROM rcarmo/ubuntu-python:onbuild
# or FROM rcarmo/ubuntu-python:3.8-onbuild-amd64 if you prefer to specify your architecture
# for a flask server
EXPOSE 5000
CMD python manage.py runserver
Dont' forget to build your image:
docker build --rm=true -t rcarmo/app .
You can also access bash
inside the container:
docker run --rm -ti rcarmo/ubuntu-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 rcarmo/app
Details
- Builds the Python interpreter with optimizations enabled, for a significant performance boost
- You can use the
latest
oronbuild
tags, but every variant is tagged with its architecture and build step purpose - Uses
make altinstall
to have Python 3.8 coexist with the built-in Ubuntu Python (which is nearly impossible to eradicate anyway) - Just like the main
python
docker image, it creates useful symlinks that are expected to exist, e.g.python3.8
>python
,pip3.8
>pip
, etc.)