Alireza
Alireza

Reputation: 6868

Why installing custom python packages using RUN in Dockerfile does not work?

I've read the below link for installing custom modules on docker:

but I'm using docker file and I'm trying to install my custom module in Dockerfile as follow:

RUN python myPythonModule/setup.py install

Now when I build docker image it shows that it is installing my custom image. When I try to run the newly build docker image with docker run it shows the error below:

Traceback (most recent call last):
  File "my_app.py", line 5, in <module>
    from myPythonModule import rpc
ImportError: No module named myPythonModule

I have copied the module to where Dockerfile is. How exactly should I install my custom python packages in docker?

Upvotes: 2

Views: 3647

Answers (2)

Adam
Adam

Reputation: 4172

You could also use pip to install local packages

WORKDIR ./myPythonModule
RUN pip install .

Upvotes: 6

Tarun Lalwani
Tarun Lalwani

Reputation: 146630

Try these

RUN cd myPythonModule && python setup.py install

or

RUN cd myPythonModule && PYTHONPATH=. python setup.py install

Upvotes: 1

Related Questions