2016-08-04 16 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文檔中以避免混淆。