65

『干货​』Go语言使用Docker Remote API ,举个栗子!

 6 years ago
source link: http://mp.weixin.qq.com/s/m6TEJ5cnbp5-I5Gs5-bCyw?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

『干货​』Go语言使用Docker Remote API ,举个栗子!

Original 精灵云-穆红卫 Ghostcloud 2017-12-15 09:25 Posted on

Docker Remote API是一个取代远程命令行界面(rcli)的REST API。我们使用命令行工具cURL来处理url相关操作。cURL可以发送请求、获取以及发送数据、检索信息。通过Docker Remote API,我们可以实现Docker操作的图形化执行方式,对于不熟悉命令行管理Docker的使用者来说,也可以轻松的管理远程机器上的Docker。

Centos7虚拟机配置docker remote api开放端口

方法1:

Image

方法2:

Image

关闭防火墙(为了别的电脑可以访问端口):

测试:

测试事例参考:

http://blog.csdn.net/ztsinghua/article/details/51657296

API列表参考:

https://docs.docker.com/engine/api/v1.22/#2-endpoints

go语言代码获取容器信息

安装gocurl

如果你想下面代码在你的电脑上运行,只需修改方面里面的url和端口为自己虚拟机的IP和端口即可。

代码只实现从虚拟机获取容器信息,其他方法正在学习中。

输出内容:

- End -


Image

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK