Docker入门教程(八)Docker Remote API

时间:2023-03-08 15:32:36
Docker入门教程(八)Docker Remote API

Docker入门教程(八)Docker Remote API

【编者的话】DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第八篇,重点介绍了Docker Remote API。

Docker系列教程的上一篇文章中,我们学习了Docker Hub 以及 Docker Registry API。在本文中,让我们来看看Docker Remote API。

Docker Remote API

Docker Remote API是一个取代远程命令行界面(rcli)的REST API。本文中,我们将使用命令行工具cURL来处理url相关操作。cURL可以发送请求、获取以及发送数据、检索信息。

容器列表 获取所有容器的清单:
GET /containers/json

Docker入门教程(八)Docker Remote API

创建新容器。命令如下:
POST /containers/create

Docker入门教程(八)Docker Remote API

监控容器。使用容器id获取该容器底层信息:
GET /containers/(id)/json

Docker入门教程(八)Docker Remote API

进程列表。获取容器内进程的清单:
GET /containers/(id)/top

Docker入门教程(八)Docker Remote API

容器日志。获取容器的标准输出和错误日志:
GET /containers/(id)/logs

Docker入门教程(八)Docker Remote API

导出容器。导出容器内容:
GET /containers/(id)/export

Docker入门教程(八)Docker Remote API

启动容器。如下:
POST /containers/(id)/start

Docker入门教程(八)Docker Remote API

停止容器。命令如下:
POST /containers/(id)/stop

Docker入门教程(八)Docker Remote API

重启容器,如下:
POST /containers/(id)/restart

Docker入门教程(八)Docker Remote API

终止容器:
POST /containers/(id)/kill

Docker入门教程(八)Docker Remote API

现在,我们已经带你走过了Docker API的第二站,Docker系列教程的下一篇文章会介绍有关镜像的Docker Remote API命令。我们所有的Docker系列教程你都可以在这里找到。