Here are the steps to run Tensorflow on Mac using Docker
1) Install docker
https://docs.docker.com/docker-for-mac/install
2)Launch docker container with Tensorflow CPU binary image and launch a Jupyter notebook
docker run -it -v /MY_LOCAL_COMPUTER_DIR:/MAPPED_DIR_ON_DOCKER -p 8888:8888 -p 6006:6006 tensorflow/tensorflow
Note: -v is to map your specified local directory to a directory on Docker. In this way, you can make your specified local directory accessible in your Docker instance. In my example command below, I specified this local directory on my computer /Users/weishungchung/aiformankind to be made available on Docker instance as /aiformankind.
docker run -it -v /Users/weishungchung/aiformankind:/aiformankind -p 8888:8888 -p 6006:6006 tensorflow/tensorflow
3) Copy the Jupyter notebook URL printed on the console (replace localhost with 192.168.99.100, this is docker-machine default ip)
http://192.168.99.100:8888/?token=7b91b5a355727bcf3ae1da7135a96e68bca40ccad673bf21
4) Log into Jupyter using the given token
5) Open the hello_tensorflow.ipynb notebook and run it
6) Open and run the 3_mnist_from_scratch.ipynb
7) Install Keras
Log into docker container
Open another terminal, we want to log into container to install Keras.
On the terminal, run the command below
eval "$(docker-machine env default)"
Find your container id by running docker ps
You can see your container id in the console printout. In this example, mine is 2b89e5ae9430
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2b89e5ae9430 tensorflow/tensorflow "/run_jupyter.sh --a…" 41 minutes ago Up 41 minutes 0.0.0.0:6006->6006/tcp, 0.0.0.0:8888->8888/tcp dazzling_villani
Then log into container by running the following command
(In this example, 2b89e5ae9430 is the container id)
docker exec -it 2b89e5ae9430 bash
8) Once you are in the container, you are ready to install Keras
pip install keras
9) Verify Keras version by running the following python command
python -c 'import keras; print(keras.__version__)'