首先开启docker API 操作
vi /usr/lib/systemd/system/docker.service
修改或者添加一行配置:
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:6066-H unix:///var/run/docker.sock
保存之后重启docker:
systemctl daemon-reload
systemctl restart docker
输入curl localhost:6000/info 有信息说明配置OK
容器操作
(1)查询docker系统信息
curl -X GET http://localhost:6000/info
具体信息略
(2)查询docker版本信息
curl -X GET http://localhost:6000/version
(3)创建容器
curl -X POST -H "Content-Type: application/json" -d '{ "Image": "harbor.yunwei.com/demo/mysql :test", "Env": ["MYSQL_ROOT_PASSWORD=123456"], "ExposedPorts": { "3306/tcp": {} }, "HostConfig": { "PortBindings": { "3306/tcp": [{"HostIp": "","HostPort": "3306"}] } }, "NetworkSettings": { "Ports": { "5000/tcp": [{"HostIp": "0.0.0.0","HostPort": "3306"}] } } }' http://localhost:6000/containers/create
( 4 ) 启动容器
curl -X POST -H "Content-Type: application/json" http://localhost:6000/containers/b20699b792b3/start
(5)删除
curl -X POST -H "Content-Type: application/json" http://localhost:6000/containers/b20699b792b3/stop
curl -X DELETE http://localhost:6000/containers/b20699b792b3
镜像操作
(1) 查询容器镜像信息
curl -X GET http://localhost:6000/images/quay.io/prometheus/node-exporter:v0.15.2/json
(2) 容器变化提交镜像
curl -X GET http://localhost:6000/containers/840568589bb2/changes
网友评论