Examples using the Docker Engine SDKs and Docker API

After you install Docker, you can install the Go and Python SDKs and also try out the Docker Engine API.

Each of these examples show how to perform a given Docker operation using the Go and Python SDKs and the HTTP API using curl.

Run a container

This first example shows how to run a container using the Docker API. On the command line, you would use the docker run command, but this is just as easy to do from your own apps too.

This is the equivalent of typing docker run alpine echo hello world at the command prompt:

Run a container in the background

You can also run containers in the background, the equivalent of typing docker run -d bfirsh/reticulate-splines:

List and manage containers

You can use the API to list containers that are running, just like using docker ps:

Stop all running containers

Now that you know what containers exist, you can perform operations on them. This example stops all running containers.

Note: Don’t run this on a production server.

Also, if you are using swarm services, the containers stop, but Docker creates new ones to keep the service running in its configured state.

Print the logs of a specific container

You can also perform actions on individual containers. This example prints the logs of a container given its ID. You need to modify the code before running it to change the hard-coded ID of the container to print the logs for.

List all images

List the images on your Engine, similar to docker image ls:

Pull an image

Pull an image, like docker pull:

Pull an image with authentication

Pull an image, like docker pull, with authentication:

Note: Credentials are sent in the clear.

Docker’s official registries use HTTPS.

Private registries should also be configured to use HTTPS.

Commit a container

Commit a container to create an image from its contents:

Docker Engine SDKs and API 的开发2的更多相关文章

  1. Docker Engine SDKs and API 的开发1

    Develop with Docker Engine SDKs and API Docker provides an API for interacting with the Docker daemo ...

  2. API接口开发 配置、实现、测试

    Yii2 基于RESTful架构的 advanced版API接口开发 配置.实现.测试 环境配置: 开启服务器伪静态 本处以apache为例,查看apache的conf目录下httpd.conf,找到 ...

  3. Docker Machine 和 Docker Engine 的区别

    Docker Engine 当人们提到 Docker,一般而言,大家说的是 Docker Engine,如下图:  它是一个 client-server application. Docker Eng ...

  4. Install Docker Engine on CentOS 在CentOS 7 上安装Docker

    Install Docker Engine on CentOS OS Requirements 系统要求 To install Docker Engine,you need a maintained ...

  5. 在Ubuntu上安装Docker Engine

    在Ubuntu上安装Docker Engine 这篇文章是介绍如何在在Ubuntu上安装Docker Engine,就是Google翻译官方文档的版本,英语好的直接官方原文.原文 要在Ubuntu上开 ...

  6. 启动docker报错Failed to listen on Docker Socket for the API.

    1.启动时报错查看日志发现 # journalctl -xe Failed to listen on Docker Socket for the API. 查找socket这个配置文件,修改如下 # ...

  7. Google Map API V3开发(1)

    Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...

  8. Google Map API V3开发(2)

    Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...

  9. Google Map API V3开发(3)

    Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...

随机推荐

  1. Linux基础命令---ifcfg

    ifcfg ifcfg是一个简单的脚本替换iconfig命令,它可以设置网络接口的ip地址. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedo ...

  2. Git从远程仓库里拉取一条本地不存在的分支方法

    Git从远程仓库里拉取一条本地不存在的分支方法 从远程仓库里拉取一条本地不存在的分支时,进入到对应目录先执行git fetch然后再执行git checkout -b 本地分支名 origin/远程分 ...

  3. window、linux安装jdk,excel 导入oracle,WebService,window 端口查看,svn服务安装,oracle用户解锁

    内存泄露分析插件http://download.eclipse.org/mat/1.3/update-site/birt插件http://download.eclipse.org//birt/upda ...

  4. 关于Vue中的 render: h => h(App) 具体是什么含义?

    render: h => h(App) 是下面内容的缩写: render: function (createElement) { return createElement(App); } 进一步 ...

  5. sass中的循环判断条件语句

    @if $lte7:true !default;//是否兼容ie6,7 //inline-block //ie6-7 *display: inline;*zoom:1; @mixin inline-b ...

  6. Python cv2 OpenCV 中传统图片格式与 base64 转换

    Base64是网络上最常见的用于传输8Bit字节码的编码方式之一,是一种基于64个可打印字符来表示二进制数据的方法.通过http传输图片常常将图片数据转换成base64之后再进行传输. Base64简 ...

  7. strpos 的正确使用方式

    首先简单介绍下strpos函数: strpos函数是查找某个字符在字符串中的位置:这里需要明确这个函数的作用: 这个函数得到的是位置:如果存在:返回数字:否则返回的是false: 而很多时候我们拿这个 ...

  8. 【题解】Luogu P2147 [SDOI2008]洞穴勘测

    原题传送门 这题用Link-Cut-Tree解决,Link-Cut-Tree详解 我不太会踩爆Link-Cut-Tree的并查集做法qaq 我们用Link-Cut-Tree维护连通性(十分无脑) Co ...

  9. 使用Http协议Post上传文件

    转载:http://www.cnblogs.com/softidea/p/5745369.html 转载:https://blog.csdn.net/huanongying131/article/de ...

  10. Git和Jenkins日记之没有新提交代码

    日期:2017/3/9 今天查看Jenkins运行代码记录的日志时,发现并没有昨天新提交的代码,然后查看了Jenkins的测试项目中所有的自动化测试用例, 并没有看到昨天新提交的测试用例,又查看了gi ...