How do you add a path to PYTHONPATH in a Dockerfile
Solution 1:
Just add an ENV
entry in your Dockerfile
:
ENV PYTHONPATH "${PYTHONPATH}:/your/custom/path"
Or set PYTHONPATH
in your startup script.
Solution 2:
You're setting the python path correctly, but your command is not being run by a shell, so the environment variable PYTHONPATH
is not considered.
chang your CMD
from "exec" form to "shell" form:
CMD python control/control_file/job.py
From the Docs:
Note: Unlike the shell form, the exec form does not invoke a command shell. This means that normal shell processing does not happen. For example, CMD [ "echo", "$HOME" ] will not do variable substitution on $HOME. If you want shell processing then either use the shell form or execute a shell directly, for example: CMD [ "sh", "-c", "echo $HOME" ]. When using the exec form and executing a shell directly, as in the case for the shell form, it is the shell that is doing the environment variable expansion, not docker.