curl: (7) Failed to connect to localhost port 9000 - aws-lambda

We are using AWS Lambda runtime interface emulator to run our app locally inside Docker using lite-server
I start my docker container with:
docker run -p 9000:8080 image-name
The curl http://localhost:9000 command is returning
curl: (7) Failed to connect to localhost port 9000 after 0 ms: Connection refused
I am a newbie to Docker, can anyone please suggest how to fix it?

Related

Elasticsearch not able to connect to port 9200

After setting up elasticsearch and kibana, I installed curl.
I tried running this command on terminal:
curl -X GET https://localhost:9200
And it is giving this error.
curl: (7) Failed to connect to localhost port 9200 after 6 ms: Couldn't connect to server
Does anyone know how to resolve this issue?

Docker issue during gatling performance test

I have a spring boot application, and I run a performance test on it, using Gatling.
The issue is that after a few requests where everything works OK, the server returns connection refused and no other requests are working.
Gatling log looks like this:
---- Requests ------------------------------------------------------------------
> Global (OK=14 KO=1001 )
> POST /template (OK=13 KO=938 )
> PUT /feedback (OK=1 KO=63 )
---- Errors --------------------------------------------------------------------
> j.n.ConnectException: Connection refused: no further informati 577 (57,64%)
on
> j.i.IOException: Premature close 240 (23,98%)
> j.n.c.ClosedChannelException 184 (18,38%)
When I create a manual request using curl, returns:
$ curl https://localhost:8087
curl: (7) Failed to connect to localhost port 8087: Connection refused
If I connect to docker and do the request:
$ docker exec -it web /bin/bash
root#794f9e808f14:/# curl https://localhost:8443
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html
SSL handshake failed, as expected, but this means that the server is up an running.
The port is mapped in docker:
$ docker port web
8443/tcp -> 0.0.0.0:8087
8443/tcp -> :::8087
After restart, all thing happen again.
I'm using docker on a WSL Ubuntu. Not sure if this matters too much. What can I do to make this connection more stable?

Docker with "--network host" does not allow to access to port of application

I have Spring Boot app inside docker and I am running my app like this:
docker run --rm --network host --name myapp1 myapp
But when i am trying to access it from host machine it fails:
my_machine:~ root$ curl localhost:8081/someendpoint -v
* Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8081 failed: Connection refused
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connection failed
* connect to 127.0.0.1 port 8081 failed: Connection refused
* Failed to connect to localhost port 8081: Connection refused
* Closing connection 0
curl: (7) Failed to connect to localhost port 8081: Connection refused
It is not clear for me - why it is not working ?
It works fine from inside of docker.
Also myapp have no problems with connection to external docker images/internet.
Please help.
From https://docs.docker.com/network/host/
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.
Since you said you were using macOS, --network host will not work properly. I believe the underlying reason is that, outside of Linux, a virtual machine is used to host the containers. The host whose network the container shares is the VM's, not the physical host's.

Docker for Mac not forwarding ports

I'm trying to start elasticsearch 2.4.6 on my Mac (HighSierra).
Using: Docker Kitematic 0.17.2, Docker for Mac 18.06.1
After I download and run selected image in container I have
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dc5e1f90ce24 elasticsearch:2.4.6 "/docker-entrypoint.…" 13 hours ago Up 3 minutes 0.0.0.0:32782->9200/tcp, 0.0.0.0:32781->9300/tcp elasticsearch
But Elastic cannot be reached out on 9200, 9300
curl 'http://localhost:9200/?pretty'
curl: (7) Failed to connect to localhost port 9200: Connection refused
curl 'http://0.0.0.0:9200/?pretty'
curl: (7) Failed to connect to 0.0.0.0 port 9200: Connection refused
Isn't 0.0.0.0 should be available?
The answer was pretty clear, thanks Val. But to make it easier I changed in Kitematic mapping ports to 9200, 9300, so now I have
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a817c85926dc elasticsearch:2.4.6 "/docker-entrypoint.…" 4 minutes ago Up 4 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp elasticsearch
As I expected

Unable to access hosted app from docker in Windows

I started to play around with docker for a while and got stuck with the below:
Here's my Environment:
Windows 10
boot2docker/Docker version 1.12.0
Virtual box 5.0.24
this is what i'm trying to do:
$ docker run -itp 8090:8090 lamp
root#8ebc390337be:/# service apache2 start
* Starting web server apache2 *
root#8ebc390337be:/# service mysql start
* Starting MySQL database server mysqld [ OK ]
root#8ebc390337be:/#
deattached from container and then
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8ebc390337be lamp "/bin/bash" 13 minutes ago Up 13 minutes 0.0.0.0:8090->8090/tcp happy_brown
$ docker inspect $(docker ps -q) | grep IPA
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAMConfig": null,
"IPAddress": "172.17.0.2",
now when i try to run
$ curl 172.17.0.2:8090
curl: (7) Failed to connect to 172.17.0.2 port 8090: Timed out
then i tried
$ docker-machine ip default
192.168.99.100
$ curl 192.168.99.100:8090
curl: (7) Failed to connect to 192.168.99.100 port 8090: Connection refused
i did go through this accessing-a-docker-container-url-on-windows-host but it didn't help me.
i should be able to access the url from inside and outside the docker.
Could someone help me to troubleshoot
This is the ip address you should be using 192.168.99.100
I expect the problem is that your apache server is on port 80 inside the container, not 8090, i.e. your docker command should be:
$ docker run -itp 8090:80 linode/lamp
Which means map port 8090 on the outside host (192.168.99.100) to port 80 inside the container.

Resources