I was trying to run a simple docker container with Tensorflow available (first with CPU). I thought it would be a good idea to setup my Dockerimage only once (i.e. not update the tensorflow version every time I run a container).
To do this I was suggested to do as follow in my Dockerfile (the comment came from source that gave me the suggestion):
# This means you derive your docker image from the tensorflow docker image
FROM gcr.io/tensorflow/tensorflow
however, when I ran my Docker container I did pip list
and didn't see Tensorflow available anywhere plus when I ran my script I got the familiar error:
ImportError: No module named 'tensorflow'
I thought of a way to solve this by just having my Dockerfile explicitly pip3 install
tensorflow. I planned to make a bash script and have my Dockerfile run it:
# bash script intall_tensorflow.sh
# to install Tensorflow in container
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0rc1-py3-none-any.whl
pip3 install --upgrade $TF_BINARY_URL
and then just add to the docker file:
RUN sh intall_tensorflow.sh
however, my intuition tells me this might be wrong or too hacky. Why would I need the tensorflow base image FROM gcr.io/tensorflow/tensorflow
in the first place if I am just going to manually install Tensorflow later anyway?
I tried researching online what gcr.io/tensorflow/tensorflow
might be doing but I have not found anything super useful. Does someone know what is the proper way to have Tensorflow available in a Docker container from the image itself (i.e. from building the Docker image)?
Sorry if I'm being really dense but it just feels I'm doing something wrong and I couldn't find something online that addressed my question.
After looking at the answer it seems that the main issue might be that python 3 cannot find tensorflow for some reason but python 2 can. Does that mean that I need to directly install TensorFlow myself (with pip in the docker image) for the right version of TensorFlow to be available?