I've also have a mac and in general, I've found I can't connect to internal IP addresses from outside docker. I'm not an expert of docker but you can find information here.
Now, even if you could access Hot Rod from outside the docker container, it's a bit more tricky due to the topology information that the server sends to the client. Sebastian, one of the Infinispan developers, have been working on a solution to make this easier (see here). That solution is not yet usable in an official release though.
So, my general recommendation is that if you want to access Infinispan remotely via Hot Rod, you do it from within docker itself. So, have your application that uses Java Hot Rod client running inside docker. Then, maybe have a way for your application to expose a route or some HTTP entry point to the outside. When you do that, it all works fine.
Btw, one final thing: from what I remember, on a mac, docker ports are exposed externally. So, if you need to address in docker on port 1234, I think you can get to it by accessing it from outside on localhost:1234. Another of my colleagues, Gustavo, is more knowledgable on this particular topic even if he does not run mac.
Are you using Docker for Mac or Docker Machine (the one who needs a virtual machine)?
With Docker for Mac, it's not possible to access the container from outside using the IP (more details here) but if you using Docker Machine (on a Mac) you can add a route to the docker machine IP and then the access will work.
Here are the steps with Docker Machine:
1) Make sure you have docker already, check with 'docker -v'
2) Run the machine installer
curl -L https://github.com/docker/machine/releases/download/v0.12.0/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && \
chmod +x /usr/local/bin/docker-machine
3) Create the default machine:
docker-machine create default
4) Set the shell
eval $(docker-machine env default)
5) Run the container
docker run -it jboss/infinispan-server
6) Infinispan will print something like
09:44:13,364 INFO [org.infinispan.server.endpoint] (MSC service thread 1-1) DGENDPT10001: HotRodServer listening on 172.17.0.2:11222
7) Add the route
sudo route -n add 172.17.0.0/16 `docker-machine ip default`
Now you can access the server by IP directly, you can test with telnet:
➜ ~ telnet 172.17.0.2 11222
Connected to 172.17.0.2.
Escape character is '^]'.
I found this other thread that seemed to help as I am not using Docker Machine:
I added this entry:
<hotrod-connector socket-binding="hotrod" cache-container="clustered">
<topology-state-transfer external-host="localhost" external-port="11222" lazy-retrieval="false" lock-timeout="1000" replication-timeout="5000"/>
This allowed me to connect on the Mac. This is fine for me as the Mac is only used for local development. On Linux, this seems to be working without having to put an external host and external port. I am able to telnet 172.17.0.2 11222 there.
Also found that if I want to connect without using 172.17.0.2 and instead use the linux box hostaddress:11222 I need to put external-host and external port or it will keep trying to connect to 172.17.0.2.
Thanks for the help!