Docker Community Forums

Share and learn in the Docker community.

Python Environment Fails From Pip Entrypoint in Docker

(Luke Samaha) #1

Hope this is a reasonable starting point for this question since the problem is straightforward and only shows up when I dockerize. Suggestions for other forums welcomed.

I am having trouble with the python env when I run the Dockerfile in lwsamaha/docker-dervisher (shown below). When I install the pip package I published at lwsamaha/dervisher in a fresh virtualenv, I am able to exercise the entrypoint declared in dervisher (tied to the main function in

From docker, I can run the main function directly, using the same python as the entrypoint. I can also enter that same python and verify package dependencies from the interactive shell.

But, when I exercise the package endpoint in the docker container at lwsamaha/docker-dervisher, my python environment cannot find basic package dependencies.

For Example:

docker run -i -t lwsamaha/docker-dervisher
dervisher --version
      File "/usr/local/bin/dervisher", line 5, in <module>
        from pkg_resources import load_entry_point <...>
      pkg_resources.DistributionNotFound: unittest2==0.8.0

My Dockerfile at lwsamaha/docker-dervisher:

FROM debian:wheezy
RUN DEBIAN_FRONTEND=noninteractive \
    apt-get update && \
    DEBIAN_FRONTEND=noninteractive \
    apt-get install -y \
RUN pip install -U pip
RUN pip install boto
RUN DEBIAN_FRONTEND=noninteractive \
    apt-get clean autoclean && \
    apt-get autoremove
RUN pip install dervisher
# ENTRYPOINT ["dervisher"]

Pip entrypoint into python:

cat $(which dervisher)
# EASY-INSTALL-ENTRY-SCRIPT: 'dervisher==0.0.9','console_scripts','dervisher'
__requires__ = 'dervisher==0.0.9'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
        load_entry_point('dervisher==0.0.9', 'console_scripts', 'dervisher')()

Example of working python invocation within the docker container:

/usr/bin/python /usr/local/lib/python2.7/dist-packages/dervisher/ 3 3
> a dervisher starts whirling at 3 rpm

The python package installs and runs but the docker container does something different with the python environment loaded via the entry point.

Any advice would be greatly appreciated!