Difficulty accessing Docker's API

244 views Asked by At

I was struggling to get connected to the Docker API running on a RedHat 7.1 VM, the docker API is running on both a TCP port and a UNIX socket.

To configure this I set -H OPTIONS as follows:

OPTIONS='--selinux-enabled -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock'

in the file:

/etc/sysconfig/docker

Running the docker client on the same box, it connected OK to the docker daemon via either communication path:

docker images

or

docker -H=tcp://127.0.0.1:2375 images

both work equally well.

I was unable to get any sense out of it from another box, I figured the first thing to do would be to prove I can connect to port 2375 from elsewhere. I was having no joy when I tried:

telnet 10.30.144.66 2375
2

There are 2 answers

0
user835745 On BEST ANSWER

I figured it must be a firewall problem but it took a while longer before I realised it was the firewall built into Linux.

To make 2375 accessable:

Use one of the following depending on your distro

sudo firewall-cmd --zone=public --add-port=2375/tcp --permanent
sudo firewall-cmd --reload

OR

sudo iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 2375 -j ACCEPT
sudo /sbin/service iptables save
0
rinkush sharda On

I was facing similar problem when my IntelliJ IDE was not able to connect docker engine API installed on RHEL.

It got resolved with following:

firewall-cmd --add-port=2376/tcp --permanent

firewall-cmd --reload

systemctl restart docker

enter image description here

enter image description here