Reputation: 35
Docker version 17.12.0-ce, build c97c6d6
OS: Debian GNU/Linux 9 (stretch)
It's my Dockerfile:
FROM ubuntu:14.04
EXPOSE 5432
build the container:
$ docker build -t expose_5432_port .
run the container:
docker run -ti expose_5432_port /bin/bash
I try to connect the port inside the container:
root@5f15a7ebd280:/# nc -v -z 127.0.0.1 5432
nc: connect to 127.0.0.1 port 5432 (tcp) failed: Connection refused
How to connect the port?
Upvotes: 2
Views: 1476
Reputation: 14903
This is expected.
EXPOSE opens a way to connect to port 5432 in the container but as it states connect to 127.0.0.1 port 5432 (tcp) failed: Connection refused
, you are able to connect/reach to the port successfully but since there is nothing running on that port it's saying connection refused. You got to make some application run on port 5432.
Ref- https://serverfault.com/questions/725262/what-causes-the-connection-refused-message
Upvotes: 2