0
votes

I have a wildfly swarm app running in a docker container in Amazon EC2.

Here is my Docker ps:

913171ca1a34        xxxxxxxxxxx/myrepository:osapp2.0   "java -jar /app/Or..."   55 minutes ago      Up 55 minutes       8080/tcp, 0.0.0.0:4000->80/tcp   elastic_yonath

netstat -ano | grep 4000 gives following output
tcp        0      0 :::4000                     :::*                        LISTEN      off (0.00/0/0)

 netstat -ano | grep 80
udp        0      0 fe80::841:a6ff:fe76:c70c:546 :::*                                    off (0.00/0/0)
udp        0      0 :::53880                    :::*                                    off (0.00/0/0)
unix  3      [ ]         STREAM     CONNECTED     9800

I have enabled Port 80 in security Group in my EC2 in inbound

I have removed ::1 from the /etc/hosts file based on other entires in the StackOverflow.

I am getting when using curl:

"curl http://locahost:4000"
curl: (56) Recv failure: Connection reset by peer

"curl http://localhost:8080"
curl: (56) Recv failure: Connection reset by peer

I am able to run my docker in my local system.

What am I doing wrong?

Here is my IPtables:

sudo iptables -S
-P INPUT ACCEPT

-P FORWARD DROP

-P OUTPUT ACCEPT

-N DOCKER

-N DOCKER-ISOLATION

-A FORWARD -j DOCKER-ISOLATION

-A FORWARD -o docker0 -j DOCKER

-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

-A FORWARD -i docker0 ! -o docker0 -j ACCEPT

-A FORWARD -i docker0 -o docker0 -j ACCEPT

-A DOCKER -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 80 -j ACCEPT

-A DOCKER-ISOLATION -j RETURN

i did a netstat -antp, here the port is listed like an IPV6 address ? How can i run my docker with IPV4 configuration

sudo netstat -antp Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name

tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2294/rpcbind

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2481/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2511/sendmail

tcp 0 0 0.0.0.0:51501 0.0.0.0:*
LISTEN 2315/rpc.statd

tcp 0 300 172.30.1.61:22 202.60.62.100:39334 ESTABLISHED 4539/sshd

tcp 0 0 :::111 :::* LISTEN 2294/rpcbind

tcp 0 0 :::22 :::* LISTEN 2481/sshd

tcp 0 0 :::36475 :::* LISTEN 2315/rpc.statd

tcp 0 0 :::4000 :::* LISTEN 4431/docker-proxy

1
Are you really using http:\localhost? You know it's http://localhost, right?stdunbar
Yes i was using locahost, but before this posting to get the error message again, i made a mistake by using http:\\locahost. I have updated the correct error message in my post now. Thanks for catching the same.Raj
serverfault.com/questions/769578/… This is relevant for my issue. I am able to curl inside my container. But i dont understand the solution listed here.Raj
docker exec -it d86aed3df80e bash then curl localhost:8080/rest/orderapp?ordernumber=101&&offset=1, I am able to access my service.Raj
this the docker run command for the above line docker run -d -p 8080:80 raxxxxx/myrepository:osapp3.0Raj

1 Answers

0
votes

This link showed me a way "https://serverfault.com/questions/769578/curl-56-recv-failure-connection-reset-by-peer-when-hitting-docker-container"

I was able to connect to docker bash and was able to curl the url

so i did two things 1) In my Maven POM.xml i added a configuration to set a 0.0.0.0
or 2) I could have passed the bind address in my entry point tag in the docker file

Then i used port 8080 in docker run command

docker run -d -p 8080:8080 rajxxxxxx/myrepository:osapp3.0

now i am able to curl " http://localhost:8080/rest/orderapp?ordernumber=102&&offset=1" in EC2