How do you add a path to PYTHONPATH
in a Dockerfile? So that when the container is run it has the correct PYTHONPATH
? I'm completely new to Docker.
I've added ENV PYTHONPATH "${PYTHONPATH}:/control"
to the Dockerfile as I want to add the directory /control
to PYTHONPATH
.
When I access the container's bash with docker exec -it trusting_spence bash
and open python and run the commands below the directory control
is not on the list.
import sys print(sys.path)
FROM python:2 RUN pip install requests pymongo RUN mkdir control COPY control_file/ /control ENV PYTHONPATH "${PYTHONPATH}:/control" CMD ["python","control/control_file/job.py"]
RUN mkdir -p /var/www/html/foo creates the foo directory inside the filesystem of your container. docker-compose. yml ./code:/var/www/html "hides" the content of /var/www/html in the container filesystem behind the contents of ./code on the host filesystem.
Just add an ENV
entry in your Dockerfile
:
ENV PYTHONPATH "${PYTHONPATH}:/your/custom/path"
Or set PYTHONPATH
in your startup script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With