为什么orientDB连接到docker的localhost被拒绝

I did build orientDB and appserver on docker. They are running as well. This is list containers on docker:

core@localhost ~ $ docker  ps
CONTAINER ID        IMAGE                      COMMAND                CREATED
       STATUS              PORTS
NAMES
01abef0204a7        fxrialab/appserver:latest   /usr/sbin/httpd -D F   30 minute
s ago      Up 30 minutes       0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
appserver
f6d0631bb092        fxrialab/orient:latest      /bin/sh -c cd /opt/o   30 minute
s ago      Up 30 minutes       0.0.0.0:2424->2424/tcp, 0.0.0.0:2480->2480/tcp
appserver/db,orient
ebc1386250b9        fxrialab/data:latest        /usr/sbin/sshd -D      30 minute
s ago      Up 30 minutes       0.0.0.0:2200->22/tcp
data

Also i did create database on orientDB. I think orient is working fine. However when i login to my website. I got errors "Connection refused" like this:

Socket error #111: Connection refused

• vendors/OrientDB/OrientDB.php:254 OrientDBSocket->__construct('localhost','2424',30)
• apps/models/DB.php:11 OrientDB->__construct('localhost','2424')

I dont know what reason althought i did test fine on local when i enabled server.bat file. Ah, i using orientdb-1.7

Thank for advance !

localhost is a synonim for ip address 127.0.0.1

your binds are for 0.0.0.0

I am not familiar with OrientDB, but I believe that what you are facing is ports access problem (server configuration), not software problem (in this case software is OrientDB). Most servers are configured to block all ports, unless specifically allowed - for security reasons, so that noone can connect to the server on those blocked ports.

So, what is probably happening is that your local server is fine with using those ports, and remote server is secured and thus prevents connections.

Docker is running a virtual machine with separate network interface for each containers. Thus if your appserver connects to localhost, it won't see the orientdb.

You need to update your configuration to lookup the proper environment variable for the link (see http://docs.docker.com/userguide/dockerlinks/) or just use the db host. Docker injects a hostname into /etc/hosts for each linked container.

I've found cause of this issue, because im config HOST to connect is wrong. It's not localhost because docker uses its own internal IP's. In ssh type docker inspect orient then use global variables for config to access to IP & Port.