對於配置泊塢窗守護程序端口的更多詳細信息,refer configure-docker-daemon-port
一旦泊塢端口配置,您可以訪問泊塢窗的API在遠程主機。
JSON輸入文件:
API來創建容器:
curl -X POST http://192.168.56.101:6000/containers/create -d @container_create.json --header "Content-Type: application/json" | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 602 100 90 100 512 1737 9883 --:--:-- --:--:-- --:--:-- 10039
{
"Warnings": null,
"Id": "f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940"
}
產生的ID是容器ID和狀態都將無效/運行。
用於啓動創建容器的API。
# curl -X POST http://192.168.56.101:6000/containers/f5d3273e48350/start | jq . % Total % Received % Xferd Average Speed Time Time Time Current
API來檢查狀態/檢查容器:
# curl -X GET http://192.168.56.101:6000/containers/f5d3273e48350/json | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4076 0 4076 0 0 278k 0 --:--:-- --:--:-- --:--:-- 306k
{
"NetworkSettings": {
"Networks": {
"bridge": {
"MacAddress": "02:42:ac:11:00:03",
"GlobalIPv6PrefixLen": 0,
"GlobalIPv6Address": "",
"IPv6Gateway": "",
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "689d6b65ce1b06c93b2c70f41760a3e7fb2b50697d71cd9c1f39c64c865e5fa6",
"EndpointID": "76bf1f8638d1ff0387e6c3fe89e8ccab1670c709ad550f9acc6f46e559654bee",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16
}
},
"MacAddress": "02:42:ac:11:00:03",
"SecondaryIPAddresses": null,
"SandboxKey": "/var/run/docker/netns/24a031d9dfda",
"Ports": {
"0/tcp": null
},
"LinkLocalIPv6PrefixLen": 0,
"LinkLocalIPv6Address": "",
"HairpinMode": false,
"SandboxID": "24a031d9dfda70026a875f4841269c5e790b12ccafcc11869111faa240020b99",
"Bridge": "",
"SecondaryIPv6Addresses": null,
"EndpointID": "76bf1f8638d1ff0387e6c3fe89e8ccab1670c709ad550f9acc6f46e559654bee",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": ""
},
},
"AttachStderr": true,
"AttachStdout": true,
"AttachStdin": true,
"User": "",
"Domainname": "",
"Hostname": "f5d3273e4835",
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"ArgsEscaped": true,
"Image": "ubuntu:14.04",
<*************REMOVING THE OUTPUT CONTENT********>
"ExecIDs": null,
"HostnamePath": "/var/lib/docker/containers/f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940/hostname",
"ResolvConfPath": "/var/lib/docker/containers/f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940/resolv.conf",
"Image": "sha256:132b7427a3b40f958aaeae8716e0cbb2177658d2410554ed142e583ef522309f",
"State": {
"FinishedAt": "0001-01-01T00:00:00Z",
"StartedAt": "2017-06-09T06:53:45.120357144Z",
"Error": "",
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"Path": "/bin/bash",
"Created": "2017-06-09T06:52:51.820429355Z",
"Id": "f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940",
"HostsPath": "/var/lib/docker/containers/f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940/hosts",
"LogPath": "/var/lib/docker/containers/f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940/f5d3273e48350d606bd8b9d2a5bd876dc5c2d1a73183f876a1dd56473cad8940-json.log",
"Name": "/objective_bartik",
"RestartCount": 0,
"Driver": "aufs",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "docker-default"
}
請參閱本作的詳細信息:
How to build an Image using Docker API?
How to commit Docker Container using API
希望這個信息對他有幫助。
有什麼不清楚的錯誤信息?請求主體必須是空的。 – Henry
對不起,我錯過了發送錯誤我發送空請求正文。修改上面的問題。 –
這裏有幫助:https://github.com/docker/compose/issues/4039? –