I tried to follow this question: How to connect to netcat running in docker container?
I have
C:\Users\Chloe\workspace\spinsci>docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0df9daa8d8cc b7bd807e363a "/bin/sh -c /bin/ash" 9 seconds ago Up 6 seconds 0.0.0.0:1300->1300/tcp optimistic_newton
C:\Users\Chloe\workspace\spinsci>docker exec -it 0df9daa8d8cc /bin/ash
/ # nc -l -p 1300
On my host computer, I try to connect and it fails:
$ nc -vv localhost 1300
nc: connect to localhost port 1300 (tcp) failed: Connection refused
nc: connect to localhost port 1300 (tcp) failed: Connection refused
$ nc 127.0.0.1 1300
$ nc 0.0.0.0 1300
$ telnet localhost 1300
Trying ::1...
Connection failed: Connection refused
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
My Dockerfile
is merely
FROM alpine:latest
EXPOSE 1300
CMD /bin/ash
Running docker inspect 0df9daa8d8cc
yields
...
"HostConfig": {
"PortBindings": {
"1300/tcp": [
{
"HostIp": "",
"HostPort": "1300"
}
]
},
...
"NetworkSettings": {
"Ports": {
"1300/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "1300"
}
]
},
...
"Networks": {
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
Using Docker Toolbox (Engine 19.03.5) because Windows 8.1.