Docker Community Forums

Share and learn in the Docker community.

Unable to access docker exposed port on windows machine


(Krishna81m) #1

On my windows host, I am unable to access the cassandra container port outside host although they are exposed correctly.

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                            NAMES
56be0fca9cdf        59cd9efc1425        "/bin/bash"         12 minutes ago      Up 12 minutes       0.0.0.0:9042->9042/tcp, 0.0.0.0:9160->9160/tcp   mad_hypatia

$ docker-machine ip default
192.168.99.100

telnet> open 192.168.99.100 9160
Trying 192.168.99.100...
telnet: Unable to connect to remote host: Connection refused
telnet>

More info:
$ docker inspect 56be0fca9cdf
[
{
“Id”: “56be0fca9cdfb422492ec9e24d73113e3bde36223f5ce1263f5968b5a1813279”,
“Created”: “2016-01-26T23:53:09.076026831Z”,
“Path”: “/bin/bash”,
“Args”: [],
“State”: {
“Status”: “running”,
“Running”: true,
“Paused”: false,
“Restarting”: false,
“OOMKilled”: false,
“Dead”: false,
“Pid”: 7165,
“ExitCode”: 0,
“Error”: “”,
“StartedAt”: “2016-01-26T23:53:09.207149085Z”,
“FinishedAt”: “0001-01-01T00:00:00Z”
},
“Image”: “59cd9efc1425f0060850e16abbeb93342b363cfb008d99dac26a2f5cb68afbce”,
“ResolvConfPath”: “/mnt/sda1/var/lib/docker/containers/56be0fca9cdfb422492ec9e24d73113e3bde36223f5ce1263f5968b5a1813279/resolv.conf”,
“HostnamePath”: “/mnt/sda1/var/lib/docker/containers/56be0fca9cdfb422492ec9e24d73113e3bde36223f5ce1263f5968b5a1813279/hostname”,
“HostsPath”: “/mnt/sda1/var/lib/docker/containers/56be0fca9cdfb422492ec9e24d73113e3bde36223f5ce1263f5968b5a1813279/hosts”,
“LogPath”: “/mnt/sda1/var/lib/docker/containers/56be0fca9cdfb422492ec9e24d73113e3bde36223f5ce1263f5968b5a1813279/56be0fca9cdfb422492ec9e24d73113e3bde36223f5ce1263f5968b5a1813279-json.log”,
“Name”: “/mad_hypatia”,
“RestartCount”: 0,
“Driver”: “aufs”,
“ExecDriver”: “native-0.2”,
“MountLabel”: “”,
“ProcessLabel”: “”,
“AppArmorProfile”: “”,
“ExecIDs”: null,
“HostConfig”: {
“Binds”: null,
“ContainerIDFile”: “”,
“LxcConf”: [],
“Memory”: 0,
“MemoryReservation”: 0,
“MemorySwap”: 0,
“KernelMemory”: 0,
“CpuShares”: 0,
“CpuPeriod”: 0,
“CpusetCpus”: “”,
“CpusetMems”: “”,
“CpuQuota”: 0,
“BlkioWeight”: 0,
“OomKillDisable”: false,
“MemorySwappiness”: -1,
“Privileged”: false,
“PortBindings”: {
“9042/tcp”: [
{
“HostIp”: “”,
“HostPort”: “9042”
}
],
“9160/tcp”: [
{
“HostIp”: “”,
“HostPort”: “9160”
}
]
},
“Links”: null,
“PublishAllPorts”: false,
“Dns”: null,
“DnsOptions”: null,
“DnsSearch”: null,
“ExtraHosts”: null,
“VolumesFrom”: [
“data”
],
“Devices”: [],
“NetworkMode”: “default”,
“IpcMode”: “”,
“PidMode”: “”,
“UTSMode”: “”,
“CapAdd”: null,
“CapDrop”: null,
“GroupAdd”: null,
“RestartPolicy”: {
“Name”: “no”,
“MaximumRetryCount”: 0
},
“SecurityOpt”: null,
“ReadonlyRootfs”: false,
“Ulimits”: null,
“LogConfig”: {
“Type”: “json-file”,
“Config”: {}
},
“CgroupParent”: “”,
“ConsoleSize”: [
61,
143
],
“VolumeDriver”: “”
},
“GraphDriver”: {
“Name”: “aufs”,
“Data”: null
},
“Mounts”: [
{
“Source”: “/c/Users/”,
“Destination”: “/shared-folder”,
“Mode”: “”,
“RW”: true
}
],
“Config”: {
“Hostname”: “56be0fca9cdf”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: true,
“AttachStdout”: true,
“AttachStderr”: true,
“ExposedPorts”: {
“9042/tcp”: {},
“9160/tcp”: {}
},
“Tty”: true,
“OpenStdin”: true,
“StdinOnce”: true,
“Env”: null,
“Cmd”: [
"/bin/bash"
],
“Image”: “59cd9efc1425”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {},
“StopSignal”: “15”
},
“NetworkSettings”: {
“Bridge”: “”,
“SandboxID”: “25de8e4036232faf25b82a80261270639bf9d5479af1c954679ffee5525d88f4”,
“HairpinMode”: false,
“LinkLocalIPv6Address”: “”,
“LinkLocalIPv6PrefixLen”: 0,
“Ports”: {
“9042/tcp”: [
{
“HostIp”: “0.0.0.0”,
“HostPort”: “9042”
}
],
“9160/tcp”: [
{
“HostIp”: “0.0.0.0”,
“HostPort”: “9160”
}
]
},
“SandboxKey”: “/var/run/docker/netns/25de8e403623”,
“SecondaryIPAddresses”: null,
“SecondaryIPv6Addresses”: null,
“EndpointID”: “19e4b2da2e4f5b214bf6abc7f4f6608222d2ddebdbd9081c00eb4f6f61f049e7”,
“Gateway”: “172.17.0.1”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“MacAddress”: “02:42:ac:11:00:02”,
“Networks”: {
“bridge”: {
“EndpointID”: “19e4b2da2e4f5b214bf6abc7f4f6608222d2ddebdbd9081c00eb4f6f61f049e7”,
“Gateway”: “172.17.0.1”,
“IPAddress”: “172.17.0.2”,
“IPPrefixLen”: 16,
“IPv6Gateway”: “”,
“GlobalIPv6Address”: “”,
“GlobalIPv6PrefixLen”: 0,
“MacAddress”: “02:42:ac:11:00:02”
}
}
}
}
]

root@56be0fca9cdf:/# nodetool info
ID                     : e1dbe0ce-d020-43ac-9618-68abbf114e73
Gossip active          : true
Thrift active          : true
Native Transport active: true
Load                   : 15.23 MB
Generation No          : 1453852422
Uptime (seconds)       : 1343
Heap Memory (MB)       : 509.91 / 992.00
^[[A^[[B^H^H^HOff Heap Memory (MB)   : 0.09
Data Center            : datacenter1
Rack                   : rack1
Exceptions             : 0
Key Cache              : entries 19, size 5.15 KB, capacity 49 MB, 507 hits, 530 requests, 0.957 recent hit rate, 14400 save period in seconds
Row Cache              : entries 0, size 0 bytes, capacity 0 bytes, 0 hits, 0 requests, NaN recent hit rate, 0 save period in seconds
Counter Cache          : entries 0, size 0 bytes, capacity 24 MB, 0 hits, 0 requests, NaN recent hit rate, 7200 save period in seconds
Token                  : (invoke with -T/--tokens to see all 256 tokens)
root@56be0fca9cdf:/# netstat -atun
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:7000          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:53343         0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:7199          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:9160          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:43364         127.0.0.1:9042          TIME_WAIT
tcp        0      0 127.0.0.1:43363         127.0.0.1:9042          TIME_WAIT
tcp6       0      0 127.0.0.1:9042          :::*                    LISTEN
tcp6       0      0 127.0.0.1:46080         127.0.0.1:7199          TIME_WAIT
tcp6       0      0 127.0.0.1:46501         127.0.0.1:53343         TIME_WAIT

Docker Toolbox Tomcat service can't access from host machine
(Jeff Anderson) #2

Hello,

In your netstat -atun output, it looks like the process listening on port 9160 is listening on 127.0.0.1. Docker forwards connections to the eth0 ip of the container, and not to the container’s 127.0.0.1. Double check that your process is configured to listen on all interfaces instead of just 127.0.0.1

Cheers!


(Krishna81m) #3

Uh oh, good catch, thanks for the quick reply, apparently the rpc_address on container is localhost, need to update it to docker-machine ip, is it possible to access these parameters inside the container?

rpc_address: localhost


(Krishna81m) #4

What is this address on container ?
$ docker inspect 2b0c4b617a8c | grep -i ip
"HostIp": “0.0.0.0”,
“HostIp”: “0.0.0.0”,
“IPAddress”: “172.17.0.2”,

Different from docker-machine ip:
$ docker-machine ip default
192.168.99.100

Updating the IP address to network IP address fixed it
root@924f6bbd5f18:/# grep “172.17” /etc/cassandra/cassandra.yaml
listen_address: 172.17.0.2
rpc_address: 172.17.0.2

root@924f6bbd5f18:/# netstat -atun
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 172.17.0.2:7000 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:57827 0.0.0.0:* LISTEN
tcp 0 0 172.17.0.2:9160 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53711 127.0.0.1:57827 TIME_WAIT
tcp 0 0 127.0.0.1:48741 127.0.0.1:7199 TIME_WAIT
tcp 0 0 127.0.0.1:37530 127.0.0.1:33500 TIME_WAIT
tcp6 0 0 172.17.0.2:9042 :::* LISTEN


(Krishna81m) #5

Now, I cannot edit the files using vi/vim?

The arrow keys do not work either wheras pgup, pgdown work fine?

root@2b0c4b617a8c:/# vim /etc/cassandra/cassandra.yaml

I had update the vimrc to get it working. Whether you see $TERM is xterm or something else, :set nocompatible or :set term=builtin_ansi in vi(m) or in ~/.vimrc without the ‘:’ in $HOME directory seem to work.

root@157dc420a530:/# cat ~/.vimrc
set nocompatible
set term=builtin_ansi