Accessing localhost of a docker container from the host - docker

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.

Related

Switching from Docker Desktop to Colima - no localhost access

Trying to switch to colima from Docker Desktop on mac but having issues reaching my containers on localhost.
Removed Docker Desktop and installed colimna/docker w homebrew. Colima starts fine.
I have a command that I use to run Dynamo:
docker run --name dynamodb -d -p 8000:8000 amazon/dynamodb-local"
When I was using Docker Desktop I could reach the database on localhost:8000. Now it's only accessible on 127.0.0.1:8000
My /etc/hosts correctly maps localhost - this is an issue with the switch. Not finding much online regarding this - any ideas? It seems that docker no longer recognizes localhost as an alias for 127.0.0.1 after the switch. Not using Kubernetes or docker compose.

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.

docker local host url not opening

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.

Unable to access web app from outside docker container

I have an ASP.Net Core web application running inside a container.
Docker for MacOS: 1.12.3
Container IP: 172.17.0.2
docker run -it -p 6000:6000 -v $(pwd):/workspace microsoft/dotnet:latest
which listens on http://*:6000
i'm able to curl the following from within the container & i'm getting the desired response.
curl http://localhost:6000 or curl http://172.17.0.2:6000
however, when i try to access the site from outside the container (on my MacOS) that's when i don't get any output.
Why am i unable to access from outside the container?
It was the port number, changed it and it worked.

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