无法使用静态IP在覆盖网络上创建docker容器

以前使用Docker 17.05,我能够创建子网10.0.7.0/24的覆盖网络,然后我能够创建一个IP 10.0.7.2的容器.

现在我使用Docker 18.03,我能够创建子网10.0.7.0/24的覆盖网络.但是我无法使用IP 10.0.7.2创建容器.
我知道10.0.7.1是网关IP.但是什么是10.0.7.2用于新的Docker(18.03).

拜托,有人可以解释为什么会这样吗?

在Docker 18.03上,
mynet是我的覆盖网络

> docker inspect mynet
[
    {
        "Name": "mynet",
        "Id": "4lq0j7thvyb8dkwt0zbbvgski",
        "Created": "2018-03-29T09:27:41.369349452Z",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.0.7.0/24",
                    "Gateway": "10.0.7.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": null,
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "4102"
        },
        "Labels": null
    }
]

docker run显示此错误:

> docker run -dit --name mycon --network mynet --ip 10.0.7.2 ubuntu:16.04
caebeda51357d8e53f11fb765c8b4a65bd6c37d6746dbbdd1b4b8be7e6235a44
docker: Error response from daemon: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded.

提前致谢.

最佳答案 检查swarm节点是否设置为availability = drain.

该问题记录在here

否则,在18.03,我没有遇到过这个问题.

如果可用性设置为活动状态,则以下网络适用于我,如果设置为耗尽,我会遇到您的问题.

docker inspect ovr2 [
    {
        "Name": "ovr2",
        "Id": "28a5i9gcnys642u059ltfcjut",
        "Created": "2018-11-20T16:26:07.458744293Z",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.0.7.0/24",
                    "Gateway": "10.0.7.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": null,
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "4097"
        },
        "Labels": null
    } ]
点赞