设为首页 收藏本站
查看: 524|回复: 0

[经验分享] 配置远程调用docker api的方法

[复制链接]

尚未签到

发表于 2017-6-3 10:42:36 | 显示全部楼层 |阅读模式
  docker默认只开了unix socket的方式进行api的调用,如下



[iyunv@docker-master ~]# curl --unix-socket /var/run/docker.sock http:/v1.24/info
{"ID":"YHL4:JMNI:EXRN:S2M6:QFGE:S4D5:DQXT:FT5N:BSUM:NQDK:RAGE:JGKV","Containers":3,"ContainersRunning":2,"ContainersPaused":0,"ContainersStopped":1,"Images":16,"Driver":"devicemapper","DriverStatus":[["Pool Name","docker-253:2-68-pool"],["Pool Blocksize","65.54 kB"],["Base Device Size","10.74 GB"],["Backing Filesystem","xfs"],["Data file","/dev/loop0"],["Metadata file","/dev/loop1"],["Data Space Used","1.8 GB"],["Data Space Total","107.4 GB"],["Data Space Available","102.3 GB"],["Metadata Space Used","3.494 MB"],["Metadata Space Total","2.147 GB"],["Metadata Space Available","2.144 GB"],["Thin Pool Minimum Free Space","10.74 GB"],["Udev Sync Supported","true"],["Deferred Removal Enabled","false"],["Deferred Deletion Enabled","false"],["Deferred Deleted Device Count","0"],["Data loop file","/dmp/dockerData/devicemapper/devicemapper/data"],["Metadata loop file","/dmp/dockerData/devicemapper/devicemapper/metadata"],["Library Version","1.02.135-RHEL7 (2016-09-28)"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["host","bridge","overlay","null"],"Authorization":null},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":false,"NFd":27,"OomKillDisable":true,"NGoroutines":33,"SystemTime":"2017-03-16T13:44:10.944251573+08:00","ExecutionDriver":"","LoggingDriver":"journald","CgroupDriver":"systemd","NEventsListener":0,"KernelVersion":"3.10.0-514.el7.x86_64","PkgVersion":"docker-common-1.12.5-14.el7.centos.x86_64","OperatingSystem":"CentOS Linux 7 (Core)","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","IndexServerName":"docker.io","RegistryConfig":{"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"aostarit.io":{"Name":"aostarit.io","Mirrors":[],"Secure":false,"Official":false},"docker.io":{"Name":"docker.io","Mirrors":["http://26152e75.m.daocloud.io"],"Secure":true,"Official":true}},"Mirrors":["http://26152e75.m.daocloud.io"]},"NCPU":4,"MemTotal":8203071488,"DockerRootDir":"/dmp/dockerData","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"docker-master","Labels":null,"ExperimentalBuild":false,"ServerVersion":"1.12.5","ClusterStore":"","ClusterAdvertise":"","SecurityOptions":["seccomp"],"Runtimes":{"docker-runc":{"path":"/usr/libexec/docker/docker-runc-current"},"runc":{"path":"docker-runc"}},"DefaultRuntime":"docker-runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null,"Nodes":0,"Managers":0,"Cluster":{"ID":"","Version":{},"CreatedAt":"0001-01-01T00:00:00Z","UpdatedAt":"0001-01-01T00:00:00Z","Spec":{"Orchestration":{},"Raft":{},"Dispatcher":{},"CAConfig":{},"TaskDefaults":{}}}},"LiveRestoreEnabled":false,"Registries":[{"Name":"docker.io","Secure":true}]}
[iyunv@docker-master ~]#
  现在开发要求远程也能调用,那么只需要在 /etc/sysconfig/docker中的option上面加上tcp的地址和端口,再重启docker即可
  -H=unix:///var/run/docker.sock -H=tcp://docker-master:8888



[iyunv@docker-master ~]# curl http://docker-master:8888/v1.24/info
{"ID":"YHL4:JMNI:EXRN:S2M6:QFGE:S4D5:DQXT:FT5N:BSUM:NQDK:RAGE:JGKV","Containers":3,"ContainersRunning":2,"ContainersPaused":0,"ContainersStopped":1,"Images":16,"Driver":"devicemapper","DriverStatus":[["Pool Name","docker-253:2-68-pool"],["Pool Blocksize","65.54 kB"],["Base Device Size","10.74 GB"],["Backing Filesystem","xfs"],["Data file","/dev/loop0"],["Metadata file","/dev/loop1"],["Data Space Used","1.8 GB"],["Data Space Total","107.4 GB"],["Data Space Available","102.3 GB"],["Metadata Space Used","3.494 MB"],["Metadata Space Total","2.147 GB"],["Metadata Space Available","2.144 GB"],["Thin Pool Minimum Free Space","10.74 GB"],["Udev Sync Supported","true"],["Deferred Removal Enabled","false"],["Deferred Deletion Enabled","false"],["Deferred Deleted Device Count","0"],["Data loop file","/dmp/dockerData/devicemapper/devicemapper/data"],["Metadata loop file","/dmp/dockerData/devicemapper/devicemapper/metadata"],["Library Version","1.02.135-RHEL7 (2016-09-28)"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["null","host","bridge","overlay"],"Authorization":null},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":false,"NFd":28,"OomKillDisable":true,"NGoroutines":34,"SystemTime":"2017-03-16T13:45:55.321032558+08:00","ExecutionDriver":"","LoggingDriver":"journald","CgroupDriver":"systemd","NEventsListener":0,"KernelVersion":"3.10.0-514.el7.x86_64","PkgVersion":"docker-common-1.12.5-14.el7.centos.x86_64","OperatingSystem":"CentOS Linux 7 (Core)","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","IndexServerName":"docker.io","RegistryConfig":{"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"aostarit.io":{"Name":"aostarit.io","Mirrors":[],"Secure":false,"Official":false},"docker.io":{"Name":"docker.io","Mirrors":["http://26152e75.m.daocloud.io"],"Secure":true,"Official":true}},"Mirrors":["http://26152e75.m.daocloud.io"]},"NCPU":4,"MemTotal":8203071488,"DockerRootDir":"/dmp/dockerData","HttpProxy":"","HttpsProxy":"","NoProxy":"","Name":"docker-master","Labels":null,"ExperimentalBuild":false,"ServerVersion":"1.12.5","ClusterStore":"","ClusterAdvertise":"","SecurityOptions":["seccomp"],"Runtimes":{"docker-runc":{"path":"/usr/libexec/docker/docker-runc-current"},"runc":{"path":"docker-runc"}},"DefaultRuntime":"docker-runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null,"Nodes":0,"Managers":0,"Cluster":{"ID":"","Version":{},"CreatedAt":"0001-01-01T00:00:00Z","UpdatedAt":"0001-01-01T00:00:00Z","Spec":{"Orchestration":{},"Raft":{},"Dispatcher":{},"CAConfig":{},"TaskDefaults":{}}}},"LiveRestoreEnabled":false,"Registries":[{"Name":"docker.io","Secure":true}]}
[iyunv@docker-master ~]#

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-383044-1-1.html 上篇帖子: Zookeeper异常org.apache.zookeeper.KeeperException$ConnectionLossException 下篇帖子: .net core 部署 centos7 初试
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表