在外部IP(VM主机)中部署正在运行的docker

时间:2019-07-08 18:09:34

标签: docker plumber

使用docker时,我的API无法在特定的IP地址(VM主机)上发布

首先,我在终端中运行文件: Rscript run.R

这工作正常,我的api已在ip地址http://35.157.131.3:8000/swagger/上启动并运行。之后,我想用docker部署它:

docker run --rm -p 8000:8000 --expose 8000 -d --name diemdiem trestletech/plumber

这表明文件已成功检测到文件,但是,当我转到api链接时,http://35.157.131.3:8000/swagger/显示404错误。

阅读docker文档后,我创建了一个容器网络,该网络指定了我希望Docker容器运行的主机IP地址:

-o "com.docker.network.bridge.host_binding_ipv4"="35.157.131.3" \
simple-network````

then, i connect the running diemdiem container to simple-network:

``` docker network connect simple-network diemdiem```
I inspect to see whether the container is connected or not:
```docker network inspect simple-network```
The result is: 

[
    {
        "Name": "simple-network",
        "Id": "95ec0c55aeb984952459edda2d4d0bb7c9eea71824e6cec184b7c61d2e807e7b",
        "Created": "2019-07-08T17:30:23.709654207Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.21.0.0/16",
                    "Gateway": "172.21.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "c83125bf68a89aebda3effe28ebee4d6323657e1427cf08fd3d63b6e411f8448": {
                "Name": "diemdiem",
                "EndpointID": "7fab3354e051dc81ef798bd86c19361f6a721b578237b3a3695cb415b1aee2e4",
                "MacAddress": "02:42:ac:15:00:02",
                "IPv4Address": "172.21.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.bridge.host_binding_ipv4": "35.157.131.3"
        },
        "Labels": {}
    }
]

The final API is still not up and running in the ip address which i specified. I appreciate your advice.

0 个答案:

没有答案