如何使用docker远程api来创建容器? [英] How to use docker remote api to create container?
问题描述
docker run -d -p 5000:5000 --restart = always --name注册表
注册表:2。
我不知道。有人可以告诉我吗谢谢!
原始答案(2015年7月):
首先创建容器:
curl -v -X POST -HContent-Type:application / json-d'{Image:registry:2。,}'http:// localhost:2376 / containers / create?name =注册表
然后启动它:
curl -v -X POST -HContent-Type:application / json-d'{PortBindings:{5000 / tcp:[{ HostPort:5000}]},RestartPolicy:{Name:always,},}'http:// localhost:2376 / containers / registry / start?name = registry
更新二月é017,对于docker 1.13+,请参阅 rocksteady 的answer ,使用类似的想法,但使用当前的 engine / api / v1.26 。
I'm new to docker. I have read the tutorial in docker remote API . In aspect of creating container. It show me too many param to fill. I want to know what is equivalent to this command :
docker run -d -p 5000:5000 --restart=always --name registry registry:2.
I have no idea about it. Can anyone tell me? Thanks!
Original answer (July 2015):
That would be (not tested directly), as in this tutorial (provided the remote API is enabled):
First create the container:
curl -v -X POST -H "Content-Type: application/json" -d '{"Image": " registry:2.",}' http://localhost:2376/containers/create?name=registry
Then start it:
curl -v -X POST -H "Content-Type: application/json" -d '{"PortBindings": { "5000/tcp": [{ "HostPort": "5000" }] },"RestartPolicy": { "Name": "always",},}' http://localhost:2376/containers/registry/start?name=registry
Update February é017, for docker 1.13+ see rocksteady's answer, using a similar idea but with the current engine/api/v1.26.
这篇关于如何使用docker远程api来创建容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!