docker local host url not opening - docker

I installed docker and with tensorflow image I am unable to open in browser with jupyter notebook.
What am I missing??
command used: docker run -it -v /home/$USER_NAME/tf_files:/tf_files gcr.io/tensorflow/tensorflow
where "gcr.io/tensorflow/tensorflow" is the tensorflow image and "/home/surya" is $HOME.
in terminal
output in browser
PS: docker installation is correct as "docker run hello-world" gives required message.

You missed to bind some ports. The official documentation of tensorflow provides the exposed ports with this command:
docker run -it -p 8888:8888 -v /home/surya/tf_files:/tf_files gcr.io/tensorflow/tensorflow
where -p 8888:8888 means: link the port 8888 of my local machine with the service in the container, which is also 8888. Then you can access the service at http://localhost:8888
Why do I have to map a port?
Your container shows the following:
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=1b3ec72ff1ed67f77a09beaee1dc4b9ad4e7aee26401b6f0
which means that you have to connect to the running process inside the container with the port 8888. To make the port of the container accessible from your local machine, you have to add -p 8888:8888 to your command. Then accessing the URL given to you from your container makes it possible to access the container's notebook via your local browser.

Related

Docker Tutorial Question: what's the hostname?

I have a question regarding the following instructions from https://jupyter-docker-stacks.readthedocs.io/en/latest/.
This command pulls the jupyter/datascience-notebook image tagged
6b49f3337709 from Docker Hub if it is not already present on the local
host. It then starts an ephemeral container running a Jupyter Server
and exposes the server on host port 10000.
docker run -it --rm -p 10000:8888 -v "${PWD}":/home/jovyan/work
jupyter/datascience-notebook:6b49f3337709
The command mounts the current working directory on the host ({PWD} in
the example command) as /home/jovyan/work in the container. The server
logs appear in the terminal.
Visiting http://<hostname>:10000/?token=<token> in a browser loads
JupyterLab.
What is the <hostname> supposed to be? I tried my computer's username and "jovyan" but neither worked in my browser.

Run a .war on a Docker container

I'm running a Java web application on a Docker cluster running those commands:
PS C:\Users\Marco\test_workspace> docker run -v test_web_application.war:/usr/local/tomcat/webapps/TestWebApplication.war -it -p 8080:8080 --network "host" -d Tomcat
The actual output confirms that the container is running:
At this point i want to access to the container through it's IP address from my host and i'm using the command inspect to identify the IP:
But, as the screenshot shows, i don't see any IP assigned.
Thus, my questions are:
Why the command --network "host" to assign an IP address shared with the host didn't worked ?
Finally, how can i access to my web application from the host ?
Command option --network="host" isn't supported for Docker for Windows (more information: https://docs.docker.com/network/host/).
You can access your application on localhost:8080 with launch option -p 8080:8080.

Port forwarding from docker container to my local desktop (container --> remote host --> local desktop)

I have a jupyter notebook running in docker container. I would like to port forward it to my local desktop browser. For that I do the below steps
1) Publish the container port to the remote host port
2) Port forward the remote host port to the localhost (desktop)
Though I tried doing this, I get an error message that "Page cannot be displayed". Can you please let me know if I am making any error with the docker commands
Publish ports (container to remote host)
docker run --runtime=nvidia -it --rm -v
/home/selva/aiaa_demo:/mnt/aiaa_spleen -p 8787:8888 $DOCKER_IMAGE jupyter
notebook /opt/nvidia/medical/annotation/examples/MSD_Task09_Spleen --ip
0.0.0.0 --allow-root --no-browser
Port forwarding in ubuntu bash screen
ssh -L 8343:127.0.0.1:8787 onegpu
The execution of above two commands doesn't help me in opening the browser in local desktop
However, when I use --network-host , it works
docker run --runtime=nvidia --network=host -it --rm -v
/home/selva/demo:/mnt/disease -p 8787:8888 $DOCKER_IMAGE jupyter
notebook /opt/nvidia/med/ann/examples/MSD --ip
0.0.0.0 --allow-root --no-browser
Can you please tell me what is the mistake with my docker command or what can be the reason as to why it isn't opening?
I am expecting to be able to open the jupyter notebook locally in my desktop without --network=host option and your help in fixing my docker command / port related issue

Accessing localhost of a docker container from the host

I am running the cloudera docker quickstart image (on windows) as explained on the this page.
I run it using:
docker run --hostname=quickstart.cloudera --privileged=true -t -i -p 7180:7180 -p 9080:9080 cloudera/quickstart:latest
It runs fine, I am able to run cloudera manager and access it using the url http://192.168.99.100:7180. So far so good. I also use tomcat with a simple app on localhost:9080 inside this same container. How do I access it on my host? I tried using http://192.168.99.100:9080 but it does not work.
Update: I fixed it by using the vm ip i.e. 192.168.99.100 instead of localhost for the server. Now it works. Thanks.

Docker in Docker: Port Mapping

I have found a similar thread, but failed to get it to work. So, the use case is
I start a container on my Linux host
docker run -i -t --privileged -p 8080:2375 mattgruter/doubledocker
When in that container, I want to start another one with GAE SDK devserver running.
At that, I need to access a running app from the host system browser.
When I start a container in the container as
docker run -i -t -p 2375:8080 image/name
I get an error saying that 2375 port is in use. I start the app, and can curl 0.0.0.0:8080 when inside both containers (when using another port 8080:8080 for example) but cannot preview the app from the host system, since lohalhost:8080 listens to 2375 port in the first container, and that port cannot be used when launching the second container.
I'm able to do that using the image jpetazzo/dind. The test I have done and worked (as an example):
From my host machine I run the container with docker installed:
docker run --privileged -t -i --rm -e LOG=file -p 18080:8080
jpetazzo/dind
Then inside the container I've pulled nginx image and run it with
docker run -d -p 8080:80 nginx
And from the host environment I can browse the nginx welcome page with http://localhost:18080
With the image you were using (mattgruter/doubledocker) I have some problem running it (something related to log attach).

Resources