I’m writing a docker script for running a python program from bitbucket, say myprogram.py. The python program uses specific functions from other files in other directories, and calls them like this:
from mydirectory.myfunction import MyFunction
Normally, if I just clone the bitbucket repository and run it, no errors occur.
My repo in bitbucket consists of the program, a docker file and some directories with scripts of functions. So I clone the repo, and then build.
When I tried to build it, it was succesful. I build it with this command:
docker build -t myprogram .
However, when I use the command (the -h is the "help" option made with argparse just to see if the program is able to run with an option):
docker run --rm -it myprogram -h
it gives me the error:
Traceback (most recent call last): File "/usr/src/myprogram.py", line 8, in <module> from mydirectory.myfunction import MyFunction ImportError: No module named 'mydirectory'
What is the best way to implement in the docker file, that the program uses functions from other scripts in other directories in the same repo in bitbucket? I’m new to docker, so any help would be appreciated! Please let me know if you need any additional information.
Source: Dockerfile Questions