I have a running container with python and pycaffe in it. If I use docker exec to enter via a bash, I can the run a python script that imports the caffe module. But it fails when using this command:
docker exec -ti dts bash -c "python /root/init_random_weights.py"
mroos@synapse:scratch$ docker exec -ti dts bash -c "python /root/init_random_weights.py" Hello Traceback (most recent call last): File "/root/init_random_weights.py", line 4, in <module> import caffe ImportError: No module named caffe
Why isn't python finding caffe when called in this manner? My .bashrc on the running container adds caffe to PYTHONPATH:
What am I misunderstanding here?
Thanks to some info here: https://docs.docker.com/engine/reference/commandline/exec/, I implemented a workaround by defining the PYTHONPATH env variable in the docker exec call as such:
docker exec -ti -w /root -e PYTHONPATH=/usr/local/caffe/python: dts bash -c "python /root/init_random_weights.py"
But I still don't understand why, in the absence of the -e option, the PYTHONPATH of my host machine is used rather than the PYTHONPATH of the .bashrc file in the container.