美文网首页docker学习历程
Docker Rest API使用入门

Docker Rest API使用入门

作者: 爱上编码 | 来源:发表于2018-12-10 14:46 被阅读33次

    首先开启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

    (3)镜像push

    (4)镜像tag

    (5)镜像pull

    相关文章

      网友评论

        本文标题:Docker Rest API使用入门

        本文链接:https://www.haomeiwen.com/subject/vqrrhqtx.html