call to connect fails with errno 111 inside a docker container

164 Views Asked by At

I have a back-end app that i deploy in a Docker container. The app is running just fine, but when I try, from within the app, to open a TCP socket (in order to connect to it with a GUI front-end from the host) by calling connect, the call fails with errno 111, namely ECONNREFUSED (connection refused).

The requested socket details: 0.0.0.0:50000

i run the image with: docker run -p 50000:50000 my_image

Both the host and the container are running Ubuntu 20.04.

Doing this directly on the host works just fine.

Any ideas?

Thanks.

1

There are 1 best solutions below

0
user1410541 On

Don't ask me why, but adding -it to the docker run command fixed it...