A minimal image with Python 2.7.10 or Python 3.4.3 of 30 mb.
3.5K
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:
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/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
_mysq is the C extension, located at /usr/lib/python2.7/site-packages/_mysql.so, and it requires a shared object file: libmysqlclient.so.18.
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/libmysqlclient.so.18. Copy this file in your image. libmysqlclient.so.18 depends on libstdc++.so.6. 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 libmysqlclient.so.18 /lib/
COPY libstdc++.so.6 /lib/
RUN pip install --use-wheel --find-links=/tmp/wheelhouse mysql-python
CMD sh
Content type
Image
Digest
sha256:bf1768c05…
Size
11.6 MB
Last updated
over 10 years ago
docker pull advancedclimatesystems/python:2.7.10