Public Repository

Last pushed: 2 years ago
Short Description
A minimal image with Python 2.7.10 or Python 3.4.3 of 30 mb.
Full Description

Python 2.7.10

Python 3.4.3


A small image (around 30 mb) build with Buildroot containing Python. The image is available with Python 2.7.10 or Python 3.4.3 and contains beside Python the following packages:

  • Pip 7.1.2
  • Setuptools 18.3.0
  • BusyBox 1.23.2
  • Wheel 0.24.0

Installing C extensions

This image doesn't contain a compiler, so you can't build C extensions in this container. If you want to use such extension, for example pycrypto, build a Wheel from pycrypto on your host. Then install pycrypto from this Wheel in your container.

[user@host] $ pip wheel --wheel-dir=wheelhouse pycrypto

Create a Dockerfile like this:

FROM advancedclimatesystems/python:2.7.10
COPY wheelhouse /tmp/wheelhouse
RUN pip install wheel
RUN pip install --use-wheel --find-links=/tmp/wheelhouse pycrypto
RUN -r /tmp/wheelhouse

CMD sh

If your C extensions uses shared libraries you might have to add them to the image. Take for example mysql-python. This DBAPI for MySQL is the default DBAPI for SqlAlchemy. If you'd create an image like above and run python -c import MySQLdb in it, you'll see an an error like this:

[user@container] $ python -c "import MySQLdb"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/MySQLdb/", line 19, in <module>
    import _mysql
ImportError: cannot open shared object file: No such file or directory

_mysq is the C extension, located at /usr/lib/python2.7/site-packages/, and it requires a shared object file:

If you have a 64-bit machine with mysqlclient-dev installed you have this object file. On my Debian system it's located at /usr/lib/x86_64-linux-gnu/ Copy this file in your image. depends on Copy this file into the image as well.

A Dockerfile which summarizes it all:

FROM advancedclimatesystems/python:2.7.10
COPY wheelhouse /tmp/wheelhouse
COPY /lib/
COPY /lib/
RUN pip install --use-wheel --find-links=/tmp/wheelhouse mysql-python 
CMD sh
Docker Pull Command

Comments (0)