19

This might just be my rookie knowledge of Docker, but I can't get the networking to work.

I'm trying to run a Mule-server via the pr3d4t0r/mule repository. I can run it, hot-swap applications but I can reach it.

I can run a local server without Docker, and it works flawlessly. But not when I try it with Docker.

When I try to do a simple curl command I get "curl: (56) Recv failure: Connection reset by peer"

curl http://localhost:8090/Sven

I have tried exposing the ports via -P and separately via -p 8090:8090 but no luck.

When the docker is running it blocks the ports (I tried running Docker and the normal server at the same time but the normal one said the ports where already in use).

When I try another Image like jboss/wildfly and I use -p 8080:8080 there's no problem, it works perfectly.

The application in the mule-server will log and respond a simple "hello World", the output says that the application is deployed, but no messages or logging while I try to reach it.

Any suggestions?

khazrak
  • 721
  • 1
  • 6
  • 11

4 Answers4

49

In my case it was actually the app that was configured incorrectly. It had localhost as host. It should have been 0.0.0.0 without this it was acting only on localhost aka the docker container but not from outside of it.

You should not need to use -net=host.

So check if there's a configuration

khazrak
  • 721
  • 1
  • 6
  • 11
  • 3
    This worked for me too but this workaround doesn't explain why. :( Does anyone know why the port forwarding doesn't work? In my case, I'm using Spring Boot and getting the error "Recv failure: Connection reset by peer" – Trevor Allred Nov 14 '14 at 17:19
  • 1
    @TrevorAllred: I think it is because docker network uses his own network namespace, so 127.0.0.1 of container is not the same as 127.0.0.1 of host – Giacomo Catenazzi Jul 16 '20 at 13:16
  • 1
    Where to configure this? – red-devil Sep 08 '20 at 10:02
  • Great but HOW did you do it? – Brian Wiley Aug 07 '21 at 01:46
  • A little background, I am dockering an Angular app. Port forwarding - `- 4200:4200` - was and is in my `docker-compose.yml` but I forced to configure my Angular app to use `0.0.0.0` over `localhost`. After that tiny change it worked. IDK why docker works like this. Do you know why docker did not port forwarding. – Kasir Barati Jun 20 '22 at 12:35
3

In application.properties need set 0.0.0.0 ip not 127.0.0.0.

Gennady
  • 31
  • 3
  • A little background, I am dockering an Angular app. Port forwarding - `- 4200:4200` - was and is in my `docker-compose.yml` but I forced to configure my Angular app to use `0.0.0.0` over `localhost`. After that tiny change it worked. IDK why docker works like this. Do you know why docker did not port forwarding. – Kasir Barati Jun 20 '22 at 12:38
1

error

"curl: (56) Recv failure: Connection reset by peer"

mean that no process in docker image listening to the port. Option -p is bind of port in host system and image.

-p <port in host os to be binded to>:<port in container>

So, check your image, maybe your app in container use different port and you need

-p 8080:8090
Andy Madge
  • 624
  • 5
  • 17
Ryabchenko Alexander
  • 10,057
  • 7
  • 56
  • 88
0

if you have this , comment or remove it, server.address=localhost in your application.properties

Mohammed Rafeeq
  • 2,586
  • 25
  • 26