Windows 10 Docker Container Connection - docker

I am trying to run docker on windows 10, installation worked fine. Now I am running few containers like below.
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7a86a28e4116 data-extractor_php-fpm "/usr/sbin/php-fpm7.…" About an hour ago Up 29 minutes 9000/tcp data-extractor-php-fpm
09105815a3c4 nginx:alpine "nginx -g 'daemon of…" About an hour ago Up 29 minutes 0.0.0.0:6000->80/tcp data-extractor-webserver
The nginx container is running, But may I know, how to connect to this container from browser,
normally on mac it works like below
http://localhost:6000/
May I know how to access this container in wondows 10?

Yes, found the answer by myself. It appears to be chrome issue, chrome refusing to connect to port 6000 throwing error like unsafe port, either change settings in browser or update compose file to use allowed ports by chrome, and second step will be to update hosts file map docker machine ip to localhost. Docker ip can tracable by using following command.
ipconfig
hope it helps others.

Related

How to access the application(exposed on port 7600) from docker container inside a container?

I have a Jenkins docker container running on a ec2(Amazon linux AMI) and i am able to access the jenkins container with IP:PORT on web browser.
[#~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
74db49830336 jenkins_1 "/sbin/tini -- /usr/…" 5 hours ago Up 5 hours 50000/tcp, 0.0.0.0:80->8080/tcp jenkins_1
I have created a job which will create container inside Jenkins container and which is exposed on port 7600
jenkins#74db49830336:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b4527d9ef554 cloudwaveapp_10 "runaceserver" 56 minutes ago Up 54 minutes 0.0.0.0:7600->7600/tcp, 0.0.0.0:7800->7800/tcp, 0.0.0.0:7843->7843/tcp, 9483/tcp cloudwave1
i have added(exposed) all the ports in EC2 Instance inbound rules
Issue:- I am not able to access the IP:7600 on web browser.
To map this port you need -p 7600:7600 when starting Jenkins container. So you kind of mapping the inside ports to outer system (think of onion).
Anyway - this is bad idea to run container in container. You can achieve the same when having shared volumes/network for communication. Container in container provide bigger mental load and you need to mount extra devices to the first Jenkins container.

How to access the docker container service running in same instance with instanceip and container-port

Here is the overview of the problem I am facing.
Suppose I have a instance x.x.x.x and where I am running the following services.
Docker container for prometheus running in 9090
Docker container for alertmanager running in 9093
The services are running well I can access the service using the instance url followed by their IP.
Problem:
My service 1 (Prometheus) needs to access service2 (alertmanager) with the hosturl:ip ie X.X.X.X:9090 is when trying to access X.X.X.X:9093 it is not being possible Throwing the following errors.
How I tested:
Entered inside service1 container and tried telneting it
telnet: can't connect to remote host (X.X.X.X): No route to host
I am not sure but have come to realize this is due to the docker firewall issues. if so than What can be done or what is the possible solutions for the scenario. How do I make the service2 accessible to service1 with the < hostIP :port >
docker ps result
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0ac39e87eb27 prom/alertmanager "/bin/alertmanager --" 53 minutes ago Up 53 minutes 0.0.0.0:9093->9093/tcp alertmanager_1
25a7de42d57f prom/prometheus "/bin/prometheus --co" 53 minutes ago Up 53 minutes 0.0.0.0:9090->9090/tcp
prometheus
NOTE:
I am running the services using the docker-compose. So the docker-compose solutions would be more appreciated
It looks like you're not linking your services. The proper solution would be to run both services from the same docker-compose file and link them toegether. Than you can use the docker-compose service name to access the Alertmanager in the other container from Prometheus.

localhost not working docker windows 10

I am using VS2017 docker support. VS created DockerFile for me and when I build docker-compose file, it creates the container and runs the app on 172.x.x.x IP address. But I want to run my application on localhost.
I did many things but nothing worked. Followed the docker docs as a starter and building microsoft sample app . The second link is working perfectly but I get HTTP Error 404 when tried the first link approach.
Any help is appreciated.
Most likely a different application already runs at port 80. You'll have to forward your web site to a different port, eg:
docker run -d -p 5000:80 --name myapp myasp
And point your browser to http://localhost:5000.
When you start a container you specify which inner ports will be exposed as ports on the host through the -p option. -p 80:80 exposes the inner port 80 used by web sites to the host's port 80.
Docker won't complain though if another application already listens at port 80, like IIS, another web application or any tool with a web interface that runs on 80 by default.
The solution is to:
Make sure nothing else runs on port 80 or
Forward to a different port.
Forwarding to a different port is a lot easier.
To ensure that you can connect to a port, use the telnet command, eg :
telnet localhost 5000
If you get a blank window immediatelly, it means a server is up and running on this port. If you get a message and timeout after a while, it means nobody is running. You anc use this both to check for free ports and ensure you can connect to your container web app.
PS I run into this just a week ago, as I was trying to set up a SQL Server container for tests. I run 1 default and 2 named instances already, and docker didn't complain at all when I tried to create the container. Took me a while to realize what was wrong.
In order to access the example posted on Docker Docs, that you pointed out as not working, follow the below steps,
1 - List all the running docker containers
docker ps -a
After you run this command you should be able to view all your docker containers that are currently running and you should see a container with the name webserver listed there, if you have followed the docker docs example correctly.
2 - Get the IP address where your webserver container is running. To do that run the following command.
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" webserver
You should now get the IP address which the webserver container is running, hope you are familiar with this step as it was even available within the building Microsoft sample app example that you attached with the question.
Access the IP address you get once running the above command and you should see the desired output.
Answering to your first question (accessing docker container with localhost in docker for windows), in Windows host you cannot access the container with localhost due to a limitation in the default NAT network stack. A more detailed explanation for this issue can be obtained by visiting this link. Seems like the docker documentation is not yet updated but this issue only exists in Windows hosts.
There is an issue reported for this as well - Follow this link to see that.
Hope this helps you out.
EDIT
The solution for this issue seems to be coming in a future Windows release. Yet that release comes out this limitation is available in Windows host. Follow this link -> https://github.com/MicrosoftDocs/Virtualization-Documentation/issues/181
For those who encountering this issue in 2022, changing localhost to 127.0.0.1 solved an issue for me.
There is other problem too
You must have correct order with parameters
This is WRONG
docker run container:latest -p 5001:80
This sequence start container but parameter -p is ignore, therefore container have no ports mapping
This is good
docker run -p 5001:80 container:latest

Docker does not have default machine in Windows 10

I installed Docker in Windows 10 64bit. The built is also correct and it is a pro version so it shouldn't be a problem.
Docker activated Hyper-V and created the docker machine, which I can access to load page in localhost. The syncing is also working so my Docker container is working overall (I used Laradock).
My problem is when I try to connect to the MySQL from my host machine, I can't connect through localhost or 127.0.0.1. Ports are correct too I have checked.
Amendment: If I leave the host box blank, PhpMyAdmin works. But I
still can't connet through SQLYog or other clients.
I tried doing docker-machine ip and I get this:
Error: No machine name(s) specified and no "default" machine exists.
Here's my docker ps output:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
85cce33afbe2 laradock_nginx "nginx" 12 minutes ago Up 12 minutes 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp laradock_nginx_1
f2ce18b4591c laradock_php-fpm "php-fpm" 12 minutes ago Up 12 minutes 9000/tcp laradock_php-fpm_1
23bf95305334 laradock_workspace "/sbin/my_init" 12 minutes ago Up 12 minutes 0.0.0.0:2222->22/tcp laradock_workspace_1
f7b87216173b laradock_phpmyadmin "/run.sh phpmyadmin" 12 minutes ago Up 12 minutes 0.0.0.0:8080->80/tcp laradock_phpmyadmin_1
4a87449e2bb6 laradock_mysql "docker-entrypoint.sh" 12 minutes ago Up 12 minutes 3306/tcp, 0.0.0.0:3306->1234/tcp laradock_mysql_1
After the fix:
I am still not getting the 'default' machine and can't do
docker-machine ip but by changing the port mapping from 1234 to 3306
I got SQLYog to work too. It'll do for me for now.
So I mapped opposite. I have to map to 3306 from 1234 which means I have to do "1234:3306" in my docker-compose.yml file. That worked too. :D
The discussion below, fixed my problem but I can still use some solution to why 'default' machine is not working and I can't do docker-machine ip.
VirtualBox VMs created with docker-machine (including the default one typically created during Toolbox install) will no longer start. These VMs cannot be used side-by-side with Docker for Windows.
Docker for Windows
You don't use docker-machine. You list the containers with docker ps. If you cannot access the MySQL container, then you might have forgotten to expose the port.
My problem is when I try to connect to the MySQL from my host machine, I can't connect through localhost or 127.0.0.1.
Sounds like you're connecting wrong. It is definitely running.
4a87449e2bb6 laradock_mysql "docker-entrypoint.sh" 12 minutes ago Up 12 minutes 3306/tcp, 0.0.0.0:3306->1234/tcp
Though, unclear why you mapped to port 1234

Docker espeakbox: What do I do now?

Seems real simple, but I'm not sure what to do now. I have docker on OSX and I'm want to try out espeakbox. So I ran
the command mentioned here.
to "run a container"
It's evidently running:
bash-3.2$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
705a605786c7 parente/espeakbox "/server" 34 seconds ago Up 33 seconds 0.0.0.0:8080->8080/tcp espeakbox
So, what do I do now, to use see it, hear it, etc.
Thanks.
There's full instructions on the GitHub page, so I'm loath to answer this question. However, I'm assuming the confusion is that you're not sure where the container is running. If you're using boot2docker, Just do:
$ curl http://$(boot2docker ip):8080/speech?text=hello
I assume it sends back an mp3 file.
Basically, the docker run command told Docker to forward port 8080 on the container to port 8080 on the host. When using boot2docker, the host is a Virtualbox VM, so we need to use the IP of the VM to connect to the service.

Resources