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. MyDO

    编写MyOD.java 用java MyOD XXX实现Linux下od -tx -tc XXX的功能提交测试代码和运行结果截图. od -tx -tc XXX是输出文件的十六进制数和ASCII字符或 ...

  2. python 内置函数format

    Python2.6 开始,新增了一种格式化字符串的函数 str.format(),它增强了字符串格式化的功能. 基本语法是通过 {} 和 : 来代替以前的 % . format 函数可以接受不限个参数 ...

  3. MQ(转)

    1. 到底什么时候该使用MQ? 1). 典型场景一:数据驱动的任务依赖 采用MQ的优点是: a. 不需要预留buffer,上游任务执行完,下游任务总会在第一时间被执行 b. 依赖多个任务,被多个任务依 ...

  4. CentOS7使用yum命令安装Java1.8

    CentOS7使用yum命令安装Java1.8 首先更新已安装的包:#yum update查看系统当前的java版本:#java -version==================== CentOS ...

  5. <转>jmeter(十三)常见问题及解决方法

    本博客转载自:http://www.cnblogs.com/imyalost/category/846346.html 个人感觉不错,对jmeter讲解非常详细,担心以后找不到了,所以转发出来,留着慢 ...

  6. EditPlus配置GCC

    --GCC Compile-- 命令:D:\GCC\MinGW_RP_Green\bin\gcc.exe 参数:$(FileName) -o $(FileNameNoExt).exe 初始目录:$(F ...

  7. python的ws库功能,实时获取服务器ws协议返回的数据

    # -*- coding:utf-8 -*- ''' 模块下载,帮助地址:https://github.com/liris/websocket-client#readme 模块:websocket-c ...

  8. 利用Python实现多线程聊天功能

    #-*- coding:utf-8 -*- from threading import Thread from socket import * #1.实现接收消息 def recvDate(): wh ...

  9. Windows下用cmd命令实例讲解yii2.0 的控制台定时任务

    Yii中的资源是和Web页面相关的文件,可为CSS文件,JavaScript文件,图片或视频等,资源放在Web可访问的目录下,直接被Web服务器调用. 有时候有些功能需要做到计划任务中去,因此就需要y ...

  10. Golang的数组初始化方式及for-range遍历

    package main import ( "fmt" ) func main() { ]], , } //定义并初始化长度为3的数组 fmt.Println(arr1) //[1 ...