Unable to run docker project in localhost - docker

I have installed a repo from docker and ran it using the following command,
docker run -d --name searx -p $PORT:8888 wonderfall/searx
The container was also sucessfully created but while accessing it in my browser i get the following error,
dail tcp[::1]:8888: connectex: No connection could be made because the target machine actively refused it.
Does anyone know why this error occurs? I use a windows10 system.

Just installed docker toolbox
That means you cannot use localhost directly without declaring in Virtual Box a port-forwarding rule.
First, test your service using the IP of your VM (see docker-machine ip default output)
http://<ip>:8888
Then, declare a port-forward rule:
either directly in your VirtualBox graphical interface: see "How do I configure docker compose to expose ports correctly?"
or with VBoxManage controlvm commands: see "Not able to access tomcat application on Docker VM with host(windows) IP while using docker toolbox"

Related

Problem accessing jupyter notebook from Docker Toolbox Container

I just set up a Docker Container with the Docker Toolbox and ran jupyter notebook inside the container using
docker run --name container -v %somedirectory%:%someotherdir% -d -p 127.0.0.1:8888:8888 quay.io/fenicsproject/stable:2017.2.0 'jupyter-notebook --ip=0.0.0.0'
Afterwards I can check the log of the container to see the URL and token that jupyter notebook created.
If I now go ahead and copy the link to my browser, it won't be able to connect to localhost. Accessing 127.0.0.1 does not work either.
Since the Docker Toolbox relies on Virtual Box VMs, I also tried to use the IP address of the VM, in this case 192.168.99.100:2376. According to the Kitematic UI, this is the IP:Port combination that is being published by the docker-machine and indeed this does not lead to a generic connection error. Instead the browser's output is:
Client sent an HTTP request to an HTTPS server.
I don't really know what to do from this point on. What does this "error" mean? Does it even make sense to use the VM's IP address? And most importlanty: what else can I do in order to finally get access to the jupyter notebook?
PS: I also tried the suggestions made in the threads Can't access jupyter notebook from docker and Access Jupyter notebook running on Docker container and couldn't make any of them work unfortunately.
I hope someone can help, thank you very much in advance.
You need to do two things to make this work:
Remove the 127.0.0.1 part of the port mapping; docker run -p 8888:8888 ...
Connect to the docker-machine ip address with the published port; http://192.168.99.100:8888.
Docker Toolbox runs Docker in a separate Linux virtual machine. Any docker run -p options will get interpreted from the point of view of that VM. If you docker run -p 127.0.0.1:... then the published port will be bound to the VM's lo0 localhost interface, so it won't be reachable from outside the VM.
Once you have the port published, you need to connect to that specific port. Port 2376 is typically the port to reach the Docker daemon inside the VM, with mutual TLS security; you only need this for manual docker commands. To reach services running inside the VM you need to connect to the published port (the first number in the docker run -p option).

How to access Docker Selenium hub console in browser?

I am running docker selenium hub on windows. The container is up as docker log shows. However I am confused at what is the actual hostname that the hub uses. When i use conventional Selenium hub, I can use http://localhost:4444/grid/console to check that it's running correctly. But in this case of docker, I am confused at the printing of Docker log.
I tried 0.0.0.0, localhost, 172.17.0.2 as hostname to open /grid/console in browser. None of them works.
Also when I tried to use 'netstat -a' to list all tcp connections, I do not see any of them has port 4444.
Could anyone let me know what went wrong?
You are running docker on windows, there are two things you can do.
Map your port 4444 to host when starting the container.
On windows, your container is ruining in Boot2Docker virtual machine.
So instead of http://localhost:4444/grid/console use
http://{ip of boot2docker vm}:4444/grid/console
To get IP on boot2docker machine try the following command:
docker-machine ip default
Port expose docker example:
docker run -d -p 4444:4444 --name <container-name> <image-name> 

docker running splash container but localhost does not load (windows 10)

I am following this tutorial to use splash to help with scraping webpages.I installed Docker toolbox and did these two steps:
$ docker pull scrapinghub/splash
$ docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
I think it is running correctly, based on the prompted message in Docker window, which looks like this:
However, when I open the `localhost:8050' in a web browser, it says the localhost is not working.
What might have gone wrong in this case? Thanks!
You have mapped the port to your docker host (the VM), but you have not port-forwarded that same port to your actual "localhost" (your Windows host)
You need to declare that port-forwarding in the Network settings of your VM (for instance "default"), or with VBoxManage controlvm commands.
Then and only then could you access that port (used by your VM) from your Windows host (localhost).
That or you can access that same port using the IP address of your boot2docker VM: see docker-machine ls.
#user3768495, when you use http://192.168.99.100:8050/ , you are actually using the docker-machine ip and this ip would be available on your machine only and not on the network. To map it to localhost, you do need to port-forward the same port to your localhost. I was having the same issue and I detailed the process in below link.
https://stackoverflow.com/a/35737787/4820675

Docker container not exposed on network

I am new to docker. I am running it on windows. I am trying to get a container named "ghost" (available from the Docker Hub) to work on a Windows 8.1 machine. While the container starts correctly and supposedly exposes url at http://localhost:2368, when I enter this address nothing happens. The same has happened when trying other containers from the Hub which expose urls.
I tried accessing the container's exposed URL from the IP Address I get from the "docker ip" but it failed too. I also tried running the container with the "--net="bridge"" option, to no avail. I think I'm missing something pretty basic, but I can't for the life of me figure out what. Can someone point me in the right direction?
When you install Docker on Windows that means you most likely installed boot2docker.
boot2docker starts a minimal Linux VM (based on VirtualBox) because Docker requires a Linux kernel to run. The Docker daemon is started on that VM and not on your localhost.
You can determine the VMs IP address by typing boot2docker ip on your command line. The standard boot2docker IP address is 192.168.59.103 if you did not configure something else or have multiple instances of that VM running.
So when you execute docker run --name ghost -p 2368:2368 -d ghost the port 2368 is opened at 192.168.59.103:2368. That is where you need to connect to.
For more information please read the official boot2docker documentation.
You haven't provided the complete 'docker run ...' command you executed, so I'm assuming you ran the one specified in the image's page on Docker Hub (reproduced below).
docker run --name some-ghost -p 8080:2368 -d ghost
The command is mapping Ghost's exposed port inside the container (2368) to port 8080 in your boot2docker VM. The first thing you need to do is run boot2docker ip to find out the IP address of your boot2docker VM. About the port number, you have two options:
Access Ghost via port 8080 (http://BOOT2DOCKER-IP:8080)
Change the port mapping to expose 2368 (-p 2368:2368)

Docker - Access mapr UI from host

I have installed docker on a CentOS machine. Now I am trying to run a MapR sandbox on it. After starting I get this:
Starting MapR Services.................
To manage this node go to: https://172.17.0.13:8443
But I am not able to access this URL from the windows machine in the same network as the CentOS machine.
This is an internal docker network inaccessible outside of the box. In order to access this container you need:
EXPOSE command in container (most likely it is already there)
run container with -p option
If you just specify -p port will be random - you could find it with inspect command, or you could use permanent port -p hostIp:externalPort:8443 where hostIp is address of your docker host.
After that you could access container from network as https://hostIp:externalPort

Resources