Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Java UI容器到couchDB容器的连接_Java_Docker_Connection_Port_Containers - Fatal编程技术网

从Java UI容器到couchDB容器的连接

从Java UI容器到couchDB容器的连接,java,docker,connection,port,containers,Java,Docker,Connection,Port,Containers,我有一个关于Java和couchDB的问题 我的设置: -具有数据库接口的Java UI -容器中的couchDB,在localhost:5984上公开 嗯 我在本地的Windows机器上实现了两者之间的连接,这台机器工作得非常好 现在我都用集装箱包装了,但我有一个问题: Caused by: java.net.ConnectException: Connection refused 到目前为止我所做的: Docker inspect交付了以下结果: "PortBindings": {

我有一个关于Java和couchDB的问题

我的设置: -具有数据库接口的Java UI -容器中的couchDB,在localhost:5984上公开

我在本地的Windows机器上实现了两者之间的连接,这台机器工作得非常好

现在我都用集装箱包装了,但我有一个问题:

Caused by: java.net.ConnectException: Connection refused
到目前为止我所做的:

Docker inspect交付了以下结果:

  "PortBindings": {
            "5984/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "5984"
                }
            ]
        },
以及以下各项:

"NetworkSettings": {
        "Bridge": "",
        "SandboxID": "860904f9f0d1132bdc3770a3af96627b1675865efe0491a8e51edfba143e8a7f",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "5984/tcp": [
                {
                    "HostIp": "0.0.0.0",
                    "HostPort": "5984"
                }
            ]
        },
        "SandboxKey": "/var/run/docker/netns/860904f9f0d1",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "aeff4e87630662516cd35db3d9a26804204420feed65506ff2457f13ddc82b19",
        "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": "aeff4e87630662516cd35db3d9a26804204420feed65506ff2457f13ddc82b19",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.2",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:02"
            }
        }
    }
}
我正在将我的2容器链接到:

sudo docker run -it -p 5984:5984 --name couchdb klaemo/couchdb
sudo docker run -ti --link couchdb      -e DISPLAY=$DISPLAY        -v /tmp/.X11-unix:/tmp/.X11-unix java:ui
以编程方式,我在Java代码中连接到localhost:5984(因为我的couchDB在那里运行:p)——但我的连接在容器环境中被拒绝

我需要以何种方式修改哪条语句来实现容器之间的工作连接?Bash语句中是否有错误?或者我的编程逻辑中是否有错误,因为它将容器绑定到了其他地方

期待你的回答


致以最良好的祝愿。

我终于找到了解决办法。在容器内部,my DB绑定到localhost:5984

但我的集装箱在我的机器上绑定到172.17.0.1;我的数据库可以通过172.17.0.2:5984(外部绑定)访问

因此,我不得不使用172.17.0.2作为目标IP地址