Giter Site home page Giter Site logo

python's Introduction

Maintained by: the Docker Community

This is the Git repo of the Docker "Official Image" for python (not to be confused with any official python image provided by python upstream). See the Docker Hub page for the full readme on how to use this Docker image and for information regarding contributing and issues.

The full image description on Docker Hub is generated/maintained over in the docker-library/docs repository, specifically in the python directory.

See a change merged here that doesn't show up on Docker Hub yet?

For more information about the full official images change lifecycle, see the "An image's source changed in Git, now what?" FAQ entry.

For outstanding python image PRs, check PRs with the "library/python" label on the official-images repository. For the current "source of truth" for python, see the library/python file in the official-images repository.


  • build status badge
  • build status badge
Build Status Badges (per-arch)
amd64 build status badge arm32v5 build status badge arm32v6 build status badge arm32v7 build status badge
arm64v8 build status badge i386 build status badge mips64le build status badge ppc64le build status badge
s390x build status badge windows-amd64 build status badge put-shared build status badge

python's People

Contributors

autoferrit avatar daghack avatar docker-library-bot avatar edmorley avatar gmeans avatar j0wi avatar jayh5 avatar jimnicholls avatar jnoordsij avatar kohtala avatar kondzik avatar mal avatar malor avatar mattrobenolt avatar michael-k avatar mike9005 avatar ncopa avatar noamcohen97 avatar orgads avatar pelson avatar peterdavehello avatar proppy avatar reza-ebrahimi avatar skwashd avatar stefanscherer avatar sunghwan2789 avatar tao12345666333 avatar tenzer avatar tianon avatar yosifkit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python's Issues

Excessive size of the non-slim python images

Perhaps this is not the right place for such a discussion, but I'm curious if it's really good practice to be including so many likely unnecessary modules in the non-slim images.

The slim version is 200MB, and the 2.7 onbuild you use in the example docs is 744MB, as of this writing.

Is this extra 540 MB of cruft really worth the extra transfer and load time?

python:3.5.1 image is broken

I use python:3.5.1 image, but it didn't have python and python3 command

[root@client ~]# docker run -i -t python:3.5.1 /bin/bash
root@b5df006d1d78:/# python
bash: python: command not found
root@b5df006d1d78:/# python3
bash: python3: command not found

python:3.5.0 is ok

[root@client ~]# docker run -i -t python:3.5.0 /bin/bash
root@f5dc0c6d5a04:/# python
Python 3.5.0 (default, Dec  5 2015, 22:14:04)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Images info

[root@client ~]# docker images
REPOSITORY                                 TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
python                                     3.5                 cd86406b3214        3 hours ago         688.7 MB
python                                     3.5.1               cd86406b3214        3 hours ago         688.7 MB
python                                     3.5.0               c64596cbb9b6        3 days ago          688.8 MB

apt images are unavailable

It seems like the images that apt-get hits when fetching packages are unavailable. This makes it difficult to add extra utilities to the image.

Sending build context to Docker daemon   169 kB
Sending build context to Docker daemon 
Step 0 : FROM python:3-onbuild
# Executing 3 build triggers
Trigger 0, COPY requirements.txt /usr/src/app/
Step 0 : COPY requirements.txt /usr/src/app/
 ---> Using cache
Trigger 1, RUN pip install --no-cache-dir -r requirements.txt
Step 0 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Using cache
Trigger 2, COPY . /usr/src/app
Step 0 : COPY . /usr/src/app
 ---> Using cache
 ---> 9380d71a8eae
Step 1 : RUN apt-get update && apt-get install -y netcat
 ---> Running in 2a0e61e19e17
Err http://httpredir.debian.org jessie InRelease

Err http://httpredir.debian.org jessie-updates InRelease

Err http://httpredir.debian.org jessie Release.gpg
  Could not resolve 'httpredir.debian.org'
Err http://httpredir.debian.org jessie-updates Release.gpg
  Could not resolve 'httpredir.debian.org'
Err http://security.debian.org jessie/updates InRelease

Err http://security.debian.org jessie/updates Release.gpg
  Could not resolve 'security.debian.org'
Reading package lists...
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/InRelease  

W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/InRelease  

W: Failed to fetch http://security.debian.org/dists/jessie/updates/InRelease  

W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie/Release.gpg  Could not resolve 'httpredir.debian.org'

W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-updates/Release.gpg  Could not resolve 'httpredir.debian.org'

W: Failed to fetch http://security.debian.org/dists/jessie/updates/Release.gpg  Could not resolve 'security.debian.org'

W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package netcat
The command '/bin/sh -c apt-get update && apt-get install -y netcat' returned a non-zero code: 100

Alpine variant for Python 2

I see you have a very light Alpine variant for Python 3.

Could we make the same for Python 2?

I could work on a PR if you want.

Alpine 3.3, Python 2.7.11, urllib2 SSL: CERTIFICATE_VERIFY_FAILED

FROM python:2-alpine
CMD ["python", "-c", "import urllib2; response = urllib2.urlopen('https://www.python.org')"]

is causing

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/usr/local/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 1240, in https_open
    context=self._context)
  File "/usr/local/lib/python2.7/urllib2.py", line 1197, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>

Is this normal?

The python path is not set correctly (does not include `/usr/lib/python2.7/dist-packages/`)

It is well known that the Debian packaged python libraries get installed in a non-standard directory, for instance in /usr/lib/python2.7/dist-packages/ for python2.7 (see Deviations from upstream in the Python Debian wiki).

On the other hand, these images do not install the system provided python, but install it from source so that the sys.path does not take into account the above non-standard directories; for instance, for python2.7, the path is set to

['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2',
 '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/site-packages']

If this issue is not solved, it is impossible to use system packaged python libraries; this is particularly critical for libraries that have heavy binary dependencies on other system libraries.

Should slim also install libbz2-dev

When trying to pip install pytz i get the following error message:

tarfile.CompressionError: bz2 module is not available

Imo libbz2-dev should be installed and included before building python.

lzma module was not found in python:3-slim

When I try to import the module lzma:

Python 3.5.1 (default, Jan 13 2016, 18:56:49) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lzma
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/lzma.py", line 26, in <module>
    from _lzma import *
ImportError: No module named '_lzma'

It seems that the library liblzma-dev is needed to build this module. See setup.py script.

Python should be configured/built with --enable-shared option.

Currently the Python installations are built with a command like:

RUN mkdir -p /usr/src/python \
    && curl -SL "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz" \
        | tar -xJC /usr/src/python --strip-components=1 \
    && cd /usr/src/python \
    && ./configure \
    && make -j$(nproc) \
    && make install \
    && cd / \
    && rm -rf /usr/src/python

When running configure, you should be supplying the --enable-shared option to ensure that shared libraries are built for Python. By not doing this you are preventing any application which wants to use Python as an embedded environment from working. This is because the lack of the shared library results in any embedded system failing at compile time with:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC

/usr/local/lib/libpython2.7.a: error adding symbols: Bad value

collect2: error: ld returned 1 exit status

error: command 'gcc' failed with exit status 1

This basic mistake is something that Linux distributions themselves made for many years and it took a lot of complaining and education to get them to fix their Python installations. It would be nice to see you address this and do what all decent Linux distributions do now, and have done for a while, and install Python with shared libraries.

Remove/freeze python 3.2

Lots of python libraries are dropping support for python 3.2.

Specifically, virtualenv 14.0.0 (https://virtualenv.pypa.io/en/latest/changes.html) and pip 8.0.0 (https://pip.pypa.io/en/stable/news/).

urllib3 has dropped 3.2: urllib3/urllib3#787 This means that requests (https://github.com/kennethreitz/requests) will be dropping 3.2 since it depends on urllib3.

So given that this is the trend, I propose we either remove 3.2 from here, or explicitly lock it so dependencies don't get updated like in #83.

failing builds

From the build server:

Processing python:2.7.8 ...
- failed; see bashbrew/logs/build-2014-11-05--22-02-15/build-python:2.7.8.log
...
Processing python:3.4.2 ...
- failed; see bashbrew/logs/build-2014-11-05--22-02-15/build-python:3.4.2.log
$ tail -n30 bashbrew/logs/build-2014-11-05--22-02-15/build-python:2.7.8.log
test_format
test_fpformat
test_fractions
test_frozen
test_ftplib
Exception in thread Thread-142:
Traceback (most recent call last):
  File "/usr/src/python/Lib/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/src/python/Lib/test/test_ftplib.py", line 238, in run
    asyncore.loop(timeout=0.1, count=1)
  File "/usr/src/python/Lib/asyncore.py", line 220, in loop
    poll_fun(timeout, map)
  File "/usr/src/python/Lib/asyncore.py", line 156, in poll
    read(obj)
  File "/usr/src/python/Lib/asyncore.py", line 87, in read
    obj.handle_error()
  File "/usr/src/python/Lib/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/usr/src/python/Lib/test/test_ftplib.py", line 315, in handle_read_event
    self._do_ssl_handshake()
  File "/usr/src/python/Lib/test/test_ftplib.py", line 282, in _do_ssl_handshake
    self.socket.do_handshake()
  File "/usr/src/python/Lib/ssl.py", line 310, in do_handshake
    self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:510: error:14076102:SSL routines:SSL23_GET_CLIENT_HELLO:unsupported protocol

Makefile:790: recipe for target 'test' failed
make: *** [test] Segmentation fault (core dumped)
2014/11/05 22:36:55 The command [/bin/sh -c ./configure         && make -j$(nproc)      && make EXTRATESTOPTS='--exclude test_file2k test_mhlib' test   && make install         && make clean] returned a non-zero code: 2
$ tail -n30 bashbrew/logs/build-2014-11-05--22-02-15/build-python:3.4.2.log              
  File "/usr/src/python/Lib/ssl.py", line 805, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

======================================================================
ERROR: test_protocol_sslv3 (test.test_ssl.ThreadedTests)
Connecting to an SSLv3 server with various client options
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/src/python/Lib/test/test_ssl.py", line 2190, in test_protocol_sslv3
    client_options=ssl.OP_NO_SSLv2)
  File "/usr/src/python/Lib/test/test_ssl.py", line 1907, in try_protocol_combo
    chatty=False, connectionchatty=False)
  File "/usr/src/python/Lib/test/test_ssl.py", line 1845, in server_params_test
    s.connect((HOST, server.port))
  File "/usr/src/python/Lib/ssl.py", line 841, in connect
    self._real_connect(addr, False)
  File "/usr/src/python/Lib/ssl.py", line 832, in _real_connect
    self.do_handshake()
  File "/usr/src/python/Lib/ssl.py", line 805, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:600)

----------------------------------------------------------------------
Ran 97 tests in 13.395s

FAILED (errors=2, skipped=4)
Makefile:957: recipe for target 'test' failed
make: *** [test] Error 1
2014/11/05 22:53:37 The command [/bin/sh -c ./configure         && make -j$(nproc)      && make -j$(nproc) EXTRATESTOPTS='--exclude test_shutil' test   && make install         && make clean] returned a non-zero code: 2

Should slim also install libsqlite3-dev.

Just looking through your new slim definition in place of using buildpack-deps. The later has libsqlite3-dev which is missing in slim. I would suggest checking whether the resulting Python from slim can actually import sqlite3 as usually libsqlite3-dev is required for that to be able to be built.

Docker 2.7.10 image issue

I can't seem to pull version 2.7.10 any more, I always get the following error:

Error downloading dependent layers
Error pulling image (2.7.10) from docker.io/library/python, Driver aufs failed to create image rootfs dc921aeac8d06e7bd5b2d85b8684bb7c94ed08db3f18a9b6e897827810b289de: open /var/lib/docker/aufs/layers/4c0cc976b7bbefe9abdfd8f0aae1bb3759004d3c9888c3164b38909b862c0cdf: no such file or directory

It's happening on Docker hub builds too.

Tests are not purged successfully during build on alpine

It seems that find -exec rm -rf '{}' + command that is used to purge tests and *.py[co] (https://github.com/docker-library/python/blob/master/2.7/alpine/Dockerfile#L46-L49) didn't achieve its goal. The tests are still in the image, and contribute 16~20M image size.

You can check it out by running

$ docker run --rm python:2-alpine find /usr/local \( -type d -a -name test -o -name tests \) -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \)
/usr/local/lib/python2.7/lib2to3/tests
/usr/local/lib/python2.7/ctypes/test
/usr/local/lib/python2.7/json/tests
/usr/local/lib/python2.7/sqlite3/test
/usr/local/lib/python2.7/lib-tk/test
/usr/local/lib/python2.7/unittest/test
/usr/local/lib/python2.7/distutils/tests
/usr/local/lib/python2.7/test
/usr/local/lib/python2.7/site-packages/wheel/test
/usr/local/lib/python2.7/email/test
/usr/local/lib/python2.7/bsddb/test
$ docker run --rm python:alpine find /usr/local \( -type d -a -name test -o -name tests \) -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \)
/usr/local/lib/python3.5/lib2to3/tests
/usr/local/lib/python3.5/ctypes/test
/usr/local/lib/python3.5/sqlite3/test
/usr/local/lib/python3.5/unittest/test
/usr/local/lib/python3.5/distutils/tests
/usr/local/lib/python3.5/test
/usr/local/lib/python3.5/tkinter/test

installed pip modules not available when running app in one go

I know of the onbuild images but for quick 'n' dirty I tried:

docker run -it --rm --name app -v "$PWD":/app -w /app -p 5000:5000 python:2 pip install flask flask-sqlalchemy flask-admin && python app.py 
Collecting flask
  Downloading Flask-0.10.1.tar.gz (544kB)
    100% |████████████████████████████████| 544kB 655kB/s 
Collecting flask-sqlalchemy
  Downloading Flask-SQLAlchemy-2.1.tar.gz (95kB)
    100% |████████████████████████████████| 98kB 2.1MB/s 
Collecting flask-admin
  Downloading Flask-Admin-1.4.0.tar.gz (868kB)
    100% |████████████████████████████████| 872kB 320kB/s 
Collecting Werkzeug>=0.7 (from flask)
  Downloading Werkzeug-0.11.3-py2.py3-none-any.whl (305kB)
    100% |████████████████████████████████| 307kB 1.4MB/s 
Collecting Jinja2>=2.4 (from flask)
  Downloading Jinja2-2.8-py2.py3-none-any.whl (263kB)
    100% |████████████████████████████████| 266kB 2.2MB/s 
Collecting itsdangerous>=0.21 (from flask)
  Downloading itsdangerous-0.24.tar.gz (46kB)
    100% |████████████████████████████████| 49kB 3.4MB/s 
Collecting SQLAlchemy>=0.7 (from flask-sqlalchemy)
  Downloading SQLAlchemy-1.0.11.tar.gz (4.7MB)
    100% |████████████████████████████████| 4.7MB 91kB/s 
Collecting wtforms (from flask-admin)
  Downloading WTForms-2.1.zip (553kB)
    100% |████████████████████████████████| 557kB 709kB/s 
Collecting MarkupSafe (from Jinja2>=2.4->flask)
  Downloading MarkupSafe-0.23.tar.gz
Building wheels for collected packages: flask, flask-sqlalchemy, flask-admin, itsdangerous, SQLAlchemy, wtforms, MarkupSafe
  Running setup.py bdist_wheel for flask
  Stored in directory: /root/.cache/pip/wheels/d2/db/61/cb9b80526b8f3ba89248ec0a29d6da1bb6013681c930fca987
  Running setup.py bdist_wheel for flask-sqlalchemy
  Stored in directory: /root/.cache/pip/wheels/79/20/fe/49ca207b5445eacf8f34ac4c7f2365dd344e17668cd63b8fdd
  Running setup.py bdist_wheel for flask-admin
  Stored in directory: /root/.cache/pip/wheels/0f/a2/07/57eb013025dc87d7f19443602f6a3e2b63d4457c7ac082c2c5
  Running setup.py bdist_wheel for itsdangerous
  Stored in directory: /root/.cache/pip/wheels/97/c0/b8/b37c320ff57e15f993ba0ac98013eee778920b4a7b3ebae3cf
  Running setup.py bdist_wheel for SQLAlchemy
  Stored in directory: /root/.cache/pip/wheels/56/75/7a/d0a2571fed74e00b0cf2678b4dd7924caa90ae306349c12ecb
  Running setup.py bdist_wheel for wtforms
  Stored in directory: /root/.cache/pip/wheels/06/b6/4a/6dae35583a348364dbdcc36ac0b742e05d698acee1010bcf5c
  Running setup.py bdist_wheel for MarkupSafe
  Stored in directory: /root/.cache/pip/wheels/94/a7/79/f79a998b64c1281cb99fa9bbd33cfc9b8b5775f438218d17a7
Successfully built flask flask-sqlalchemy flask-admin itsdangerous SQLAlchemy wtforms MarkupSafe
Installing collected packages: Werkzeug, MarkupSafe, Jinja2, itsdangerous, flask, SQLAlchemy, flask-sqlalchemy, wtforms, flask-admin
Successfully installed Jinja2-2.8 MarkupSafe-0.23 SQLAlchemy-1.0.11 Werkzeug-0.11.3 flask-0.10.1 flask-admin-1.4.0 flask-sqlalchemy-2.1 itsdangerous-0.24 wtforms-2.1
Traceback (most recent call last):
  File "app.py", line 2, in <module>
    from flask_sqlalchemy import SQLAlchemy
ImportError: No module named flask_sqlalchemy

But when I do:

docker run -it --rm --name app -v "$PWD":/app -w /app -p 5000:5000 python:2 bash

and pip install flask flask-sqlalchemy flask-admin manually from the bash inside the container, python app.py runs fine! I don't understand why starting this image with pip install ... && python app.py fails with ImportError.

Docker pull python 2.7 error (Core OS 835.13.0)

I would like to create an image which includes python 2.7. After docker tries to pull python image, an error occurs:

Step 0 : FROM python:2.7
Pulling repository docker.io/library/python
1ccfccb87e95: Error pulling image (2.7) from docker.io/library/python, HTTP code 400 
P code 400 f: Download complete 
a582cd499e0f: Download complete 
3c3e582d88fa: Download complete 
5901462573ab: Download complete 
c8bb6b7c8be6: Download complete 
3eeb5182fe51: Download complete 
663a06e2d361: Download complete 
48779543e2f5: Download complete 
89b49b365da8: Download complete 
45ca73266aa7: Error pulling dependent layers 
Error pulling image (2.7) from docker.io/library/python, HTTP code 400
Unable to find image 'my-example/image' locally

Docker info:

Containers: 2
Images: 39
Storage Driver: overlay
Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.2.2-coreos-r2
Operating System: CoreOS 835.13.0
CPUs: 8
Total Memory: 15.62 GiB
Name: server

Docker version:

Client:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   cedd534-dirty
 Built:        Thu Feb 18 16:25:16 UTC 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.3
 API version:  1.20
 Go version:   go1.4.2
 Git commit:   cedd534-dirty
 Built:        Thu Feb 18 16:25:16 UTC 2016
 OS/Arch:      linux/amd64

A question on stackoverflow

What may cause this problem?

Thank you.

Curses is missing

The /usr/local/lib/python2.7/lib-dynload/_curses.so is missing on the python:2.7-slim image which disables the usage of the builtin curses module.

"python:slim"

... totally needs to be a thing.

As a concrete example, it's just silly to have to download such a huge amount of largeish layers for tianon/speedtest when I am a total pru and know exactly which deps that image actually needs (as opposed to the general case, which is what the main images are for).

Could the source be copied before pip install?

Some projects break up their requirements files and then reference them from requirements.txt.

Others include a -e . to install the package.

Both those cases will fail with this image because the source is copied after the pip install command. What do you think about moving the source copy command to before the pip install (then you also don't need to copy the requirements.txt file separately).

FROM python:3.4

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ONBUILD COPY . /usr/src/app  #<-- includes requirements.txt and any `-r` dependencies in it
ONBUILD RUN pip install --no-cache-dir -r requirements.txt

readline module missing in python:2.7-slim

Python 2.7.10 (default, Jun  9 2015, 21:06:35) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import readline
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named readline

See https://docs.python.org/2/library/readline.html

Someone could argue that the python-slim only contains software relevant for servers, but sometimes it would be very helpful to get some debug interfaces working. For example iPython works way better when the readline module is available.

unused packages in python:3

Seems like some space could be saved by adding an apt-get autoremove in the Dockerfiles for the non-slim images.

Also, on an unrelated note: python:3 still pull in 3.4.x instead of 3.5, is that expected?

$ docker run --rm -it python:3 bash
root@ffaf32c0f8b5:/# apt-get autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gir1.2-freedesktop gir1.2-gdkpixbuf-2.0 gir1.2-glib-2.0 gir1.2-rsvg-2.0 libcairo-gobject2 libcairo-script-interpreter2 libcdt5 libcgraph6 libcroco3 libdjvulibre-dev libelfg0 libexif-dev libexif12
  libexpat1-dev libfontconfig1-dev libfreetype6-dev libgd3 libgirepository-1.0-1 libglib2.0-bin libgraphviz-dev libgvc6 libgvpr2 libice-dev libice6 libilmbase-dev libjasper-dev libjbig-dev libjs-excanvas
  libjs-jquery liblcms2-dev liblqr-1-0-dev liblzo2-2 libmagickcore-6-arch-config libmagickcore-6-headers libmagickwand-6-headers libopenexr-dev libpathplan4 libpcre3-dev libpcrecpp0 libpixman-1-dev
  libpthread-stubs0-dev librsvg2-2 librsvg2-common libsm-dev libsm6 libtiff5-dev libtiffxx5 libvpx1 libwmf-dev libx11-dev libxau-dev libxcb-render0-dev libxcb-shm0-dev libxcb1-dev libxdmcp-dev libxdot4
  libxext-dev libxpm4 libxrender-dev libxt-dev libxt6 mime-support pkg-config x11-common x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-render-dev x11proto-xext-dev xorg-sgml-doctools
  xtrans-dev
0 upgraded, 0 newly installed, 71 to remove and 0 not upgraded.
After this operation, 55.2 MB disk space will be freed.
Do you want to continue? [Y/n] n

Gdb doesn't work in 2.7-slim

Installed gdb with apt-get install gdb and I get:

root@516ce4c20e51:/# gdb -p 8
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 563, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 237, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 582, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 528, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 412, in _init_posix
    from _sysconfigdata import build_time_vars
  File "/usr/lib/python2.7/_sysconfigdata.py", line 6, in <module>
    from _sysconfigdata_nd import *
ImportError: No module named _sysconfigdata_nd

Reduce size of python image

I would suggest using ncdu / in the image to show candidates for purging.

E.g.:

/usr/share/doc: 82.3MiB
/usr/share/locale: 63.5MiB

A concrete example for purging would be /usr/share/doc/gcc-4.9-base/test-summaries.

Maybe localepurge could be used to only ship English locales in the default image?

Ref: #30 #37

Would a Stretch flavor be possible?

I was using python:2.7-slim with stretch for a while and got hit by a version incompatibility b/t gnupg and taskd without a non-aptitude type solution.

Check Downloaded Files

Could we add some checking of downloaded files to the Dockerfiles?

At the moment they do things like:

RUN set -x \
&& mkdir -p /usr/src/python \
&& curl -SL  "https://www.python.org/ftp/python/$PYTHON_VERSION/Python$PYTHON_VERSION.tar.xz" \
    | tar -xJC /usr/src/python --strip-components=1 \

There is no guarantee that this file hasn't been tampered with or corrupted. It would be great if we could test a checksum or signature file prior to unpacking. To see how to download files securely, have a look at the Wordpress and MongoDB Dockerfiles:

https://github.com/docker-library/wordpress/blob/990b1b00b8ca4903e11e53e908b1996fbaab3c1a/Dockerfile
https://github.com/docker-library/mongo/blob/fc66d9cbedac47806c7ae05b1b291c4ee32f6e6a/2.8/Dockerfile

Installing packages that require header files

How do I go about installing pylibmc. I am getting the following error with "pip install pylibmc":
pylibmcmodule.h:42:36: fatal error: libmemcached/memcached.h: No such file or directory

include <libmemcached/memcached.h>

apt-get and apt-cache don't appear to be available.

Any plan to have support for precise

Hi guys,
Do you have any plan to support legacy system like ubuntu precise, as a lot of existing production environment is still built on precise. If you like I would love to come up with a pull request.

Purging of system Python 3 packages.

Is there a reason you don't purge the packages:

python3 python3-minimal

They also appear to be installed by default as well as:

python python-minimal python2.7-minimal

So for Python 2 you end up with Python 2 from source code and Python 3 system packages.

And for Python 3 you end up with Python 3 from source code and Python 3 system packages.

This is from latest buildpack-deps.

python 3.5 locale of running container is still "POSIX"

It seems that #13 doesn't fix this problem.

I use the latest images (python 3.5.1).

  1. When I run the image with docker run --rm -it python /bin/bash, and then I execute "locale" in the container, I found the locale is "C.UTF-8".
  2. But when I run the image with docker run -d python python -m http.server, and then enter into the container and execute "locale", I found it's "POSIX".

I don't think it's expected, right?

Pip not found

There is an error when trying to build image from python:3.3

Sending build context to Docker daemon   279 kB
Sending build context to Docker daemon 
Step 0 : FROM python:3.3-onbuild
Pulling repository python
00418fdc2011: Download complete 
...
3f101aba692d: Download complete 
# Executing 3 build triggers
Step onbuild-0 : COPY requirements.txt /usr/src/app/
 ---> Using cache
 ---> ede8c3f1f602
Step onbuild-1 : RUN pip install -r requirements.txt
 ---> Running in 7c3fd4091813
/bin/sh: 1: pip: not found
2014/10/08 17:30:35 The command [/bin/sh -c pip install -r requirements.txt] returned a non-zero code: 127

Dockerfile contents:

FROM python:3.3-onbuild

Unable to execute 'gcc': No such file or directory

I was using pip to install cryptography lib and i get above errors. Dockerfile seems to install gcc however it doesnt have gcc.

unable to execute 'gcc': No such file or directory
unable to execute 'gcc': No such file or directory

No working compiler found, or bogus compiler options
passed to the compiler from Python's distutils module.
See the error messages above.
(If they are about -mno-fused-madd and you are on OS/X 10.8,
see http://stackoverflow.com/questions/22313407/ .)

error: Setup script exited with 1

Set the locale to C.UTF-8 for Python 3

Python 3 uses Unicode everywhere, which makes it inconvenient to use in an environment that claims not to support Unicode, such as these Docker images. The system I/O encoding ends up being "ascii", which means (for example) that non-ASCII strings simply can't be used with the print() function.

Usually, on Debian, the system's default locale would have set the encoding to UTF-8, but locales aren't installed.

The issue is easily fixed by adding one line to a Dockerfile, but I think it should be there in the Python 3 image itself so it doesn't catch people by surprise.

The line to add is:

ENV LANG C.UTF-8

Upgrade version of pip to 7.x.y

Right now I get a lot of:

You are using pip version 6.1.1, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

The size of the Python image - why 900MB?

I've just been reading up on Docker.

I like how it can containerize the entire app of each specific stack, but I don't understand why the Python image to install Docker is 900MB.

From this:

https://registry.hub.docker.com/_/python/

Some people have complained about the size.

What I would like to know is what that 900MB is made up of? Is it an OS + your engine + hundreds of C dependencies? Is it a virtualized OS only? Is it 900MB of everything in Python?

Are you basically installing a 'light' virtualized Debian OS to run Python?

If yes, I think you would be lying on this page:

https://www.docker.com/whatisdocker/

By not specifying that under certain conditions, the "Docker Engine" is coupled with an OS.

Some clarification on this will be much appreciated.

python:3 Recv failure: Connection reset by peer

Hi,
I am running docker image python:3 to run a python script as follows
docker run -it --rm --name alert -p 8955:8955 -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3 python ./main.py

Inside container:
I can access web URL: http://localhost:8955/metrics

On host:
I cannot access URL: using localhost/0.0.0.0/127.0.0.1 , it gives me below error
`[dockeradmin@vmh-qlhlido20-test1 server]$ curl -vv http://localhost:8955/metrics

  • About to connect() to localhost port 8955 (#0)
  • Trying 127.0.0.1...
  • Connected to localhost (127.0.0.1) port 8955 (#0)

    GET /metrics HTTP/1.1
    User-Agent: curl/7.29.0
    Host: localhost:8955
    Accept: /

  • Recv failure: Connection reset by peer
  • Closing connection 0
    curl: (56) Recv failure: Connection reset by peer`

while using Host IP, I get:
` curl -vv http://IP:8955/metrics

  • About to connect() to IPport 8955 (#0)
  • Trying IP...
  • Connection refused
  • Failed connect to IP:8955; Connection refused
  • Closing connection 0
    curl: (7) Failed connect to IP:8955; Connection refused
    `

docker version
Client:
Version: 1.8.2-el7
API version: 1.20
Package Version: docker-1.8.2-10.el7.x86_64
Go version: go1.4.2
Git commit: a01dc02/1.8.2
Built:
OS/Arch: linux/amd64

Server:
Version: 1.8.2-el7
API version: 1.20
Package Version:
Go version: go1.4.2
Git commit: a01dc02/1.8.2
Built:
OS/Arch: linux/amd64

docker inspect --format '{{ .NetworkSettings.IPAddress }}' alert
172.17.0.202

Please help to let me know how can it be corrected

Prevent python from being installed via apt-get

I'm using the python:2.7-wheezy docker image. In my docker file I have the following line:

RUN apt-get -y --no-install-recommends install libxml2 libxslt1.1 libxml2-dev libxslt1-dev python-libxml2 python-libxslt1

This causes apt-get to install python (which is already installed from the python box). How can I prevent this?

Wheezy versions?

We're using passenger standalone with a lot of our projects and it has some os level dependencies that unfortunately don't recognize debian jessie.

We forked this repo and changed the base image to buildpack-deps:wheezy, which seems to work fine. However, it would be nice if we could stick with official images.

Any chance at getting wheezy versions of this? We'd be more than happy to submit a PR as well.

Thanks!

Add PyPy support

A growing number of people (not the least of whom is myself :-)) prefer to run their applications with PyPy, it'd be great to have first class support.

Unable to install scipy in the python:3 image

I'm trying to install some libraries on top of the python:3 image but it isn't working due to some missing libraries, e.g. openblas, mkl, vml, guide, lapack.

Maybe they have been removed during the purge. Any ideas on how to solve it other than reinstalling them by hand?

Here's the terminal output:

$ docker run -it python:3 bash
Unable to find image 'python:3' locally
3: Pulling from library/python

Digest: sha256:d4e91d39a14154f5d5cb33048e3a8f03d3316e1acf585383519bd89a0611d3d7
Status: Downloaded newer image for python:3
root@3b9e3eb5d1d6:/# pip install scipy
Collecting scipy
  Downloading scipy-0.17.0.tar.gz (12.4MB)
    100% |████████████████████████████████| 12.4MB 37kB/s 
Collecting numpy>=1.6.2 (from scipy)
  Downloading numpy-1.10.4.tar.gz (4.1MB)
    100% |████████████████████████████████| 4.1MB 118kB/s 
Installing collected packages: numpy, scipy
  Running setup.py install for numpy
  Running setup.py install for scipy
    Complete output from command /usr/local/bin/python3.5 -c "import setuptools, tokenize;__file__='/tmp/pip-build-e9cx2_9t/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gxr2_g9y-record/install-record.txt --single-version-externally-managed --compile:
    lapack_opt_info:
    openblas_lapack_info:
      libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    lapack_mkl_info:
    mkl_info:
      libraries mkl,vml,guide not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas,tatlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries tatlas,tatlas not found in /usr/lib
      libraries lapack_atlas not found in /usr/lib
      libraries tatlas,tatlas not found in /usr/lib/x86_64-linux-gnu
      libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries satlas,satlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries satlas,satlas not found in /usr/lib
      libraries lapack_atlas not found in /usr/lib
      libraries satlas,satlas not found in /usr/lib/x86_64-linux-gnu
      libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/lib
      libraries lapack_atlas not found in /usr/lib
      libraries ptf77blas,ptcblas,atlas not found in /usr/lib/x86_64-linux-gnu
      libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries f77blas,cblas,atlas not found in /usr/local/lib
      libraries lapack_atlas not found in /usr/local/lib
      libraries f77blas,cblas,atlas not found in /usr/lib
      libraries lapack_atlas not found in /usr/lib
      libraries f77blas,cblas,atlas not found in /usr/lib/x86_64-linux-gnu
      libraries lapack_atlas not found in /usr/lib/x86_64-linux-gnu
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    /usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:1552: UserWarning:
        Atlas (http://math-atlas.sourceforge.net/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [atlas]) or by setting
        the ATLAS environment variable.
      warnings.warn(AtlasNotFoundError.__doc__)
    /usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:1563: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      warnings.warn(LapackNotFoundError.__doc__)
    /usr/local/lib/python3.5/site-packages/numpy/distutils/system_info.py:1566: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      warnings.warn(LapackSrcNotFoundError.__doc__)
    Running from scipy source directory.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-e9cx2_9t/scipy/setup.py", line 265, in <module>
        setup_package()
      File "/tmp/pip-build-e9cx2_9t/scipy/setup.py", line 262, in setup_package
        setup(**metadata)
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/core.py", line 135, in setup
        config = configuration()
      File "/tmp/pip-build-e9cx2_9t/scipy/setup.py", line 182, in configuration
        config.add_subpackage('scipy')
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
        caller_level = 2)
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
        caller_level = caller_level + 1)
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy/setup.py", line 15, in configuration
        config.add_subpackage('linalg')
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1002, in add_subpackage
        caller_level = 2)
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 971, in get_subpackage
        caller_level = caller_level + 1)
      File "/usr/local/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 908, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "scipy/linalg/setup.py", line 20, in configuration
        raise NotFoundError('no lapack/blas resources found')
    numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

PIP mis-configured(?)

Following dockerfile returns "/bin/sh: 1: pip: not found"

FROM python:2
MAINTAINER (me)
ADD ./requirements.txt /cfg/requirements.txt
RUN pip install -r /cfg/requirements.txt
VOLUME ["/home/django/app"]
EXPOSE 8000
WORKDIR /home/django/app/
CMD gunicorn blah.wsgi:application -b 0.0.0.0:8000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.