2016-08-04 70 views
0

泊坞窗版本 - V1.12 操作系统 - Ubuntu的14.04.4-LTS 聚类模式 - 群多克容器的网络模式更改为默认运行容器时

创建了一个覆盖网络: $ docker -H tcp://0.0.0.0:2375 network create --driver overlay --subnet=10.0.9.0/24 my-net

创建容器: [POST] http://localhost:2375/container/create?name={id}响应$docker inspect

{ 
"Env": [ 
     "env1=val1" 
    ], 
    "Cmd": [ 
     "/Run.sh", 
     "launch 
    ], 
    "Image": "<image>", 
    "Volumes": { 
     "/tmp" : {} 
    }, 
    "HostConfig": { 
    "NetworkMode": "my-net" 
    } 
} 

"HostConfig": { 
    "Binds": null, 
    "ContainerIDFile": "", 
    "LogConfig": { 
     "Type": "json-file", 
     "Config": {} 
    }, 
    "NetworkMode": "my-net", 
    "PortBindings": null, 
    "RestartPolicy": { 
     "Name": "", 
     "MaximumRetryCount": 0 
    }, 
    "AutoRemove": false, 
    "VolumeDriver": "", 
    "VolumesFrom": null, 
} 

这创建容器与networkMode为my-net。但是当我运行 容器使用其余的API [POST] http://localhost:2375/containers/{id}/start networkMode更改为 default

$docker inspect响应:

"HostConfig": { 
    "Binds": null, 
    "ContainerIDFile": "", 
    "LogConfig": { 
     "Type": "json-file", 
     "Config": {} 
    }, 
    "NetworkMode": "default", 
    "PortBindings": null, 
    "RestartPolicy": { 
     "Name": "", 
     "MaximumRetryCount": 0 
    }, 
    "AutoRemove": false, 
    "VolumeDriver": "", 
    "VolumesFrom": null, 
} 

回答

0

问题是与码头swarm API更改启动容器。该提交讲述了要传递的有效负载结构。所有我需要改变的是有效载荷:

[POST] http://localhost:2375/containers/{id}/start

有效载荷:

{ 
    "NetworkMode": "my-net" 
} 

所有的码头工人容器hostconfig中性能去的有效载荷。如果留空,则所有属性都将重置为默认值。这个API规范应该记录在swarm API文档中以避免混淆。

相关问题