Having difficulty accessing the Jupyter notebook when trying to run TensorFlow through Docker - windows

My problem:
Newbie to the ML field here. I am currently attempting to set up tensorflow through docker but am having some troubles getting to the jupyter notebook once tensorflow appears to be running. For future reference, I am using windows 10, powershell, python 2.7, and oracle virtualbox (v.5.0.16).
I am pretty confident that docker is working properly because I went through their setup tutorial ("Using docker from Powershell") without any issues--I was able to run the hello world example there just fine. I was also able to successfully run an ubuntu terminal with the command
docker run -it ubuntu bash
I then followed the tensorflow docker installation instructions and everything appeared to be normal--I entered the docker run command for tensorflow:
docker run -it b.gcr.io/tensorflow/tensorflow
and got this output:
[I 19:33:16.330 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 19:33:16.360 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[W 19:33:16.360 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.
[I 19:33:16.365 NotebookApp] Serving notebooks from local directory: /notebooks
[I 19:33:16.365 NotebookApp] 0 active kernels
[I 19:33:16.365 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/
[I 19:33:16.366 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
However, when I attempt to get to the jupyter notebook at localhost:8888, chrome says the site cannot be reached within a few seconds and that the server refused to connect.
Solutions I have tried:
Followed the advice in this stackoverflow post. When I run the command they suggest to start a new tensorflow container, I get the error:
exec: "./run_jupyter.sh": stat ./run_jupyter.sh: no such file or directory
docker: Error response from daemon: Container command not found or does not exist..
I also changed the port settings using virtualbox like they suggested, and this also did not seem to make a difference.
Instead of going to localhost, I tried the IP addresses listed for the driver when I use the command docker-machine ls. No luck here either.
My first attempt was using the quickstart terminal that comes with docker, and I got stuck in the same place. So now I have a "default", from when I set up docker using the quickstart terminal, and a "my-default", from when I set up docker using powershell. Stackexchange comments have said that the quickstart terminal doesn't work as well as just using powershell, so I have started using powershell instead.
Tried changing which driver was active using docker-machine env and then running the tensorflow run command for that driver's IP address, and still had no luck.
Tried skipping the jupyter notebook and just running everything from the command line through python as suggested in the next step of the tensorflow install ("Run tensorflow from the command line") and I could not even import tensorflow from there:
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
I don't know if this is possible without running jupyter first but I thought it was worth a shot. This problem might be unrelated to the one this post is about, but if anyone has an idea as to why this is, that would be helpful too.
I appreciate any and all help that is offered. Please let me know if anything I stated is vague, or if I can offer any more details on what I have tried. Thank you very much in advance.

Try adding -p 8888:888 to the docker run command.
docker run -p 8888:8888 -it b.gcr.io/tensorflow/tensorflow
Found the solution in this tensorflow issue, in a comment by HWiese1980
Since Docker usually needs to have the same operating system on the Docker host system as it's in the Docker container (well, parts that is) you need a Linux VM to run a Docker container that is based on Linux under Windows. Docker itself opens port 8888 between the VM and the container. You have to explicitly tell it to forward the port from the outside of the VM to the open Docker container port by using said parameter -p 8888:8888.

For ubuntu 14.04 I had to use the below command to specify '/bin/bash' so that it would enter the interactive console.
docker run -it gcr.io/tensorflow/tensorflow /bin/bash

Related

What's the default location for Zeppelin notebooks in the Windows file system?

On a fresh Win10 machine with fresh docker, the following command instantiates Zeppelin:
docker run -p 8080:8080 --rm --name zeppelin apache/zeppelin:0.8.1
... allowing me to create a new notebook using the GUI at http://localhost:8080/#/
... but where are these notebooks stored? What's the default path to their directory so that I can git init and get to work? With Jupyter there is a 'tree' showing clearly the location/path of all notebooks; I don't see one for Zep and an hour's Googling has not been informative.
The GUI's 'Notebook Repos' button doesn't seem to help:
With the help of this answer I've been able to view the specific .json file representing my notebook. This answers the Q of where zeppelin notebooks exist in Docker images; leaving unanswered the question of where they exist in the Windows filesystem when NOT using Docker.
If using Docker (as recommended by the Zeppelin docs) this is the recipe for finding a notebook file:
# first steps are taken in Powershell
docker ps # displays an image id for use in next line
docker commit <image_id_here> mysnapshot
docker run -t -i mysnapshot /bin/bash
# now in bash inside the Docker image
root#91f4bf850583:/zeppelin# ll notebook/2E6D1WBGT/note.json
... so (if using Docker) the best way to version-control a notebook is by using Docker versioning. This is quite different to Jupyter's approach where one can run individual .ipynb notebooks locally and version-control each of them. Having answered my own question I feel greatly more informed about Docker and the differences between Jupyter vs Zeppelin. Very curious to know if anyone can solve the original question of where notebooks are stored if running in Windows WITHOUT Docker 🙏

Tunneling from Windows 10 to Jupyter running on AWS

I'm trying to access Jupyter notebooks that are installed on AWS and I want to use a windows-10 machine to access it. The jupyter system sits behind a jump host (bastion) on aws. The process works for macs in the following way
- Instructions exist to create a ssh tunnel
- Magically the notebook is available on a browser by doing localhost:8223
The mac command for it looks like
ssh -i /pathto.id_rsa -L 8223:<some name>:8223 -f -o <some other url>
What I've been able to accomplish is the following.
- Installed putty and pageant. Set up key forwarding on putty and been able to log in to the bastion host.
- I tried foxyproxy on chrome but couldn't make much headway there.
How do I access this Jupyter notebook from windows?
Again, the set up is
windows --> [bastion] --> jupyter
I'm totally lost, any pointers or step by step instructions is much appreciated.
Try this article from my blog: https://vrnchndk.in/2017/01/27/access-blocked-websites-using-ssh-tunnel/
It has step by step instructions with screenshots as well.

Cannot find Jupyter Notebook server on port 8888 (Windows 10)

I'm trying to run a Docker container as a Jupyter Notebook on Windows 10. As shown in the screen grab, the notebook appears to be running on localhost:8888, but my browsers (Chrome and Edge) return a 'connection refused' error. I've disabled my firewall (temporarily), but that didn't help. Also, netstat does not list the port as being in use. Any idea what's going on?
Try the following:
docker run -p 8888:8888 -it simonwalkersamuel/bloch_tf:latest
-p 8888:8888 will map container port 8888 to host port 8888.
TLDR make sure you mapped the ports using -p 8888:8888. If didn't work, try 192.168.99.100:8888 instead of localhost:8888.
Situation:
I had a slightly different problem: Although I mapped the ports using -p 8888:8888, I still see the connection error when I try to reach localhost:8888 in all browsers. The firewall is checked and seems OK. It was very confusing because exactly same docker image works on my other Win 10 laptop at work.
Solution:
I have two slightly different Win 10 on my laptops. The one that has connection difficulty runs a Win 10 Home whereas the other one has a Win 10 Professional. This means, the problematic laptop only runs Docker Tools not the conventional Docker CE. Therefore, it maps communicates with the OS using 192.168.99.100 IP not the usual 127.0.0.1 or localhost. So, instead of localhost:8888 just used 192.168.99.100:8888 and it worked.
Confession!
I usually use my work laptop for running Jupyter on docker. Therefore, I did not pay enough attention to the welcome message of Docker Quickstart Terminal which clearly says docker is configured to use the default machine with IP 192.168.99.100. Hopefully, this post helps other too busy (aka careless!) people like me!
Since both laptops have very similar apps installed, I doubt anything rather than the Docker app itself causes the difference in IP addresses.
Try the following commands:
run these two command
pip install --upgrade pip
pip install --upgrade jupyter

Setting up docker on the mac: Cannot connect via localhost

I'm just setting up docker on my Mac. The installation worked and I got some containers running (following the getting-stared guide), but now I want to connect with my browser to localhost, to show a web app.
For that I'm following this guide: https://docs.docker.com/engine/userguide/containers/usingdocker/
In the last section it is said, that you simple go with your browser to: localhost:XXXXX wheras XXXXX is the port, that you found out using the command
docker ps -l
First problem: here nothing happends. The browser is showing an empty page (ERR_CONNECTION_REFUSED)
Further more in the guide it is explained, that for Mac you can check your ip address via the command:
docker-machine ip your_vm_name
Here appears the second problem: This command results in an error-message:
Host does not exist: "your_vm_name"
So my questions are:
How to set up the virtual machine (or "your_vm_name" respectively)?
Does it have to do anything with the vhosts file on my Mac OS?
Is there mybe a conflict with MAMP (which I'm also using sometimes)?
Thanks in advance!
And thanks to GianArb for the very fast answer! That solution works as well.
Just to contribute to the community, I just found out by myself, that the solution was too simple to be true.
Instead of your-vm-name use default (obviously the default-host that is set up by docker), so I just used:
docker-machine ip default
and then I got the right IP.
Hello the process to start to use docker on mac with docker-machine is like:
Create a new docker machine on virtualbox, you can use a name like "your_vm_name" or just "default" in this way you can not use the name because "default" is a keyword that docker-machine try to use when you don't specify nothing.
The problem here is, why docker-machine ip your_vm_name doesn't provide the good ip? Can you copy the result of your command
echo $DOCKER_HOST
Usually it's 192.168.99.100
thanks a lot
Actual for Mac OS:
If there is no real need in VirtualBox machine you can just remove it.
Docker can start Linux containers under Mac OS without any VirtualBox machines.
Without any VirtualBox machines, all exported ports are available on the localhost:*.
Remove docker machine
docker-machine ls
docker-machine stop default
docker-machine rm default
Make sure that you don't have the command eval $(docker-machine env ...) in your ~/.bashrc or ~/.zshrc.
Otherwise, nothing will work. You will see the error Error: No machine name(s) specified and no "default" machine exists.
By the default configuration no need to have any env variables like $DOCKER_*
In my case, the only docker installed by downloading a .dmg image from the official site works without any problems. Any versions installed via brew didn't work out of the box.
PS: tested on Mac OS 10.13 and 10.14

Porting issue with Docker

Hey I tried running the command
sudo docker run -d -P training/webapp python app.py"
from the tutorial but I keep getting the error
FATA[0000] Error response from daemon: Cannot start container.
I downloaded the image fine but the trouble occurs whenever I try to run it. I checked the port sudo docker port (name) and nothing shows up. I'm guessing the issue is that the PORTS aren't being set up properly. I have a mac and I'm using vmware with ubuntu and I downloaded the ubuntu set up for docker.
Is there anyway to fix this? Any help would be greatly appreciated.

Resources