(八)Docker Remote API

最后更新于:2022-04-01 23:05:09

# Docker入门教程(八)Docker Remote API > 【编者的话】DockerOne组织翻译了Flux7的Docker入门教程,本文是系列入门教程的第八篇,重点介绍了Docker Remote API。 在[Docker系列教程的上一篇文章](http://dockerone.com/article/107)中,我们学习了Docker Hub 以及 Docker Registry API。在本文中,让我们来看看Docker Remote API。 ### Docker Remote API Docker Remote API是一个取代远程命令行界面(rcli)的REST API。本文中,我们将使用命令行工具cURL来处理url相关操作。cURL可以发送请求、获取以及发送数据、检索信息。 容器列表 获取所有容器的清单: `GET /containers/json` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/a286ae17e2ab6d32ec27b9deb167b72c_763x711.png) 创建新容器。命令如下: `POST /containers/create` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/109b1b26d70e705fd53c8fa4c9fa2c01_763x711.png) 监控容器。使用容器id获取该容器底层信息: `GET /containers/(id)/json` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/5cdc9e7f0730971281cff4568e3fca44_763x711.png) 进程列表。获取容器内进程的清单: `GET /containers/(id)/top` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/4e5c9678c94a99a0b692c3e4e2d3b054_763x711.png) 容器日志。获取容器的标准输出和错误日志: `GET /containers/(id)/logs` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/04194702a68d522c7653bd5d434def75_761x711.png) 导出容器。导出容器内容: `GET /containers/(id)/export` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/ffd2a43472b8d41ea8b8186b2e2a611a_811x626.png) 启动容器。如下: `POST /containers/(id)/start` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/81b0f50ed70b14caacb2e8cdaeca1990_819x609.png) 停止容器。命令如下: `POST /containers/(id)/stop` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/d966e0fad6a843dee5bfc43e1eec7a4d_819x609.png) 重启容器,如下: `POST /containers/(id)/restart` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/69cad9f51521f9d34d45fd502150d3be_819x609.png) 终止容器: `POST /containers/(id)/kill` ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/0ca9e5a64861f8847dc200aea17d45c6_819x609.png) 现在,我们已经带你走过了Docker API的第二站,[Docker系列教程的下一篇文章](http://dockerone.com/article/110)会介绍有关镜像的Docker Remote API命令。我们所有的Docker系列教程你都可以在[这里](http://dockerone.com/topic/Docker%20Tutorial)找到。 > 出处:http://dockone.io/article/109 > 原文链接:[Docker Remote API](http://flux7.com/blogs/docker/docker-tutorial-series-part-8-docker-remote-api/)(翻译:[田浩浩](https://github.com/llitfkitfk) 审校:李颖杰)
';