github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/docs/reference/api/docker_remote_api_v1.20.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.20"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent="smn_remoteapi"
     8  weight = 1
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.20
    13  
    14  ## 1. Brief introduction
    15  
    16   - The Remote API has replaced `rcli`.
    17   - The daemon listens on `unix:///var/run/docker.sock` but you can
    18     [Bind Docker to another host/port or a Unix socket](
    19     /articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
    20   - The API tends to be REST. However, for some complex commands, like `attach`
    21     or `pull`, the HTTP connection is hijacked to transport `stdout`,
    22     `stdin` and `stderr`.
    23   - When the client API version is newer than the daemon's, these calls return an HTTP
    24     `400 Bad Request` error message.
    25  
    26  # 2. Endpoints
    27  
    28  ## 2.1 Containers
    29  
    30  ### List containers
    31  
    32  `GET /containers/json`
    33  
    34  List containers
    35  
    36  **Example request**:
    37  
    38      GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    39  
    40  **Example response**:
    41  
    42      HTTP/1.1 200 OK
    43      Content-Type: application/json
    44  
    45      [
    46           {
    47                   "Id": "8dfafdbc3a40",
    48                   "Image": "ubuntu:latest",
    49                   "Command": "echo 1",
    50                   "Created": 1367854155,
    51                   "Status": "Exit 0",
    52                   "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    53                   "SizeRw": 12288,
    54                   "SizeRootFs": 0
    55           },
    56           {
    57                   "Id": "9cd87474be90",
    58                   "Image": "ubuntu:latest",
    59                   "Command": "echo 222222",
    60                   "Created": 1367854155,
    61                   "Status": "Exit 0",
    62                   "Ports": [],
    63                   "SizeRw": 12288,
    64                   "SizeRootFs": 0
    65           },
    66           {
    67                   "Id": "3176a2479c92",
    68                   "Image": "ubuntu:latest",
    69                   "Command": "echo 3333333333333333",
    70                   "Created": 1367854154,
    71                   "Status": "Exit 0",
    72                   "Ports":[],
    73                   "SizeRw":12288,
    74                   "SizeRootFs":0
    75           },
    76           {
    77                   "Id": "4cb07b47f9fb",
    78                   "Image": "ubuntu:latest",
    79                   "Command": "echo 444444444444444444444444444444444",
    80                   "Created": 1367854152,
    81                   "Status": "Exit 0",
    82                   "Ports": [],
    83                   "SizeRw": 12288,
    84                   "SizeRootFs": 0
    85           }
    86      ]
    87  
    88  Query Parameters:
    89  
    90  -   **all** – 1/True/true or 0/False/false, Show all containers.
    91          Only running containers are shown by default (i.e., this defaults to false)
    92  -   **limit** – Show `limit` last created
    93          containers, include non-running ones.
    94  -   **since** – Show only containers created since Id, include
    95          non-running ones.
    96  -   **before** – Show only containers created before Id, include
    97          non-running ones.
    98  -   **size** – 1/True/true or 0/False/false, Show the containers
    99          sizes
   100  -   **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
   101    -   `exited=<int>`; -- containers with exit code of  `<int>` ;
   102    -   `status=`(`created`|`restarting`|`running`|`paused`|`exited`)
   103    -   `label=key` or `key=value` of a container label
   104  
   105  Status Codes:
   106  
   107  -   **200** – no error
   108  -   **400** – bad parameter
   109  -   **500** – server error
   110  
   111  ### Create a container
   112  
   113  `POST /containers/create`
   114  
   115  Create a container
   116  
   117  **Example request**:
   118  
   119      POST /containers/create HTTP/1.1
   120      Content-Type: application/json
   121  
   122      {
   123             "Hostname": "",
   124             "Domainname": "",
   125             "User": "",
   126             "AttachStdin": false,
   127             "AttachStdout": true,
   128             "AttachStderr": true,
   129             "Tty": false,
   130             "OpenStdin": false,
   131             "StdinOnce": false,
   132             "Env": null,
   133             "Cmd": [
   134                     "date"
   135             ],
   136             "Entrypoint": "",
   137             "Image": "ubuntu",
   138             "Labels": {
   139                     "com.example.vendor": "Acme",
   140                     "com.example.license": "GPL",
   141                     "com.example.version": "1.0"
   142             },
   143             "Volumes": {
   144                     "/tmp": {}
   145             },
   146             "WorkingDir": "",
   147             "NetworkDisabled": false,
   148             "MacAddress": "12:34:56:78:9a:bc",
   149             "ExposedPorts": {
   150                     "22/tcp": {}
   151             },
   152             "HostConfig": {
   153               "Binds": ["/tmp:/tmp"],
   154               "Links": ["redis3:redis"],
   155               "LxcConf": {"lxc.utsname":"docker"},
   156               "Memory": 0,
   157               "MemorySwap": 0,
   158               "CpuShares": 512,
   159               "CpuPeriod": 100000,
   160               "CpusetCpus": "0,1",
   161               "CpusetMems": "0,1",
   162               "BlkioWeight": 300,
   163               "OomKillDisable": false,
   164               "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   165               "PublishAllPorts": false,
   166               "Privileged": false,
   167               "ReadonlyRootfs": false,
   168               "Dns": ["8.8.8.8"],
   169               "DnsSearch": [""],
   170               "ExtraHosts": null,
   171               "VolumesFrom": ["parent", "other:ro"],
   172               "CapAdd": ["NET_ADMIN"],
   173               "CapDrop": ["MKNOD"],
   174               "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   175               "NetworkMode": "bridge",
   176               "Devices": [],
   177               "Ulimits": [{}],
   178               "LogConfig": { "Type": "json-file", "Config": {} },
   179               "SecurityOpt": [""],
   180               "CgroupParent": ""
   181            }
   182        }
   183  
   184  **Example response**:
   185  
   186        HTTP/1.1 201 Created
   187        Content-Type: application/json
   188  
   189        {
   190             "Id":"e90e34656806"
   191             "Warnings":[]
   192        }
   193  
   194  Json Parameters:
   195  
   196  -   **Hostname** - A string value containing the hostname to use for the
   197        container.
   198  -   **Domainname** - A string value containing the domain name to use
   199        for the container.
   200  -   **User** - A string value specifying the user inside the container.
   201  -   **Memory** - Memory limit in bytes.
   202  -   **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap
   203        You must use this with `memory` and make the swap value larger than `memory`.
   204  -   **CpuShares** - An integer value containing the container's CPU Shares
   205        (ie. the relative weight vs other containers).
   206  -   **CpuPeriod** - The length of a CPU period in microseconds.
   207  -   **Cpuset** - Deprecated please don't use. Use `CpusetCpus` instead. 
   208  -   **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use.
   209  -   **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
   210  -   **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
   211  -   **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
   212  -   **AttachStdin** - Boolean value, attaches to `stdin`.
   213  -   **AttachStdout** - Boolean value, attaches to `stdout`.
   214  -   **AttachStderr** - Boolean value, attaches to `stderr`.
   215  -   **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
   216  -   **OpenStdin** - Boolean value, opens stdin,
   217  -   **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects.
   218  -   **Env** - A list of environment variables in the form of `VAR=value`
   219  -   **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
   220  -   **Cmd** - Command to run specified as a string or an array of strings.
   221  -   **Entrypoint** - Set the entry point for the container as a string or an array
   222        of strings.
   223  -   **Image** - A string specifying the image name to use for the container.
   224  -   **Volumes** – An object mapping mount point paths (strings) inside the
   225        container to empty objects.
   226  -   **WorkingDir** - A string specifying the working directory for commands to
   227        run in.
   228  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   229        container
   230  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   231        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   232  -   **HostConfig**
   233      -   **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
   234             + `container_path` to create a new volume for the container
   235             + `host_path:container_path` to bind-mount a host path into the container
   236             + `host_path:container_path:ro` to make the bind-mount read-only inside the container.
   237      -   **Links** - A list of links for the container. Each link entry should be
   238            in the form of `container_name:alias`.
   239      -   **LxcConf** - LXC specific configurations. These configurations only
   240            work when using the `lxc` execution driver.
   241      -   **PortBindings** - A map of exposed container ports and the host port they
   242            should map to. A JSON object in the form
   243            `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   244            Take note that `port` is specified as a string and not an integer value.
   245      -   **PublishAllPorts** - Allocates a random host port for all of a container's
   246            exposed ports. Specified as a boolean value.
   247      -   **Privileged** - Gives the container full access to the host. Specified as
   248            a boolean value.
   249      -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   250            Specified as a boolean value.
   251      -   **Dns** - A list of DNS servers for the container to use.
   252      -   **DnsSearch** - A list of DNS search domains
   253      -   **ExtraHosts** - A list of hostnames/IP mappings to add to the
   254          container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   255      -   **VolumesFrom** - A list of volumes to inherit from another container.
   256            Specified in the form `<container name>[:<ro|rw>]`
   257      -   **CapAdd** - A list of kernel capabilities to add to the container.
   258      -   **Capdrop** - A list of kernel capabilities to drop from the container.
   259      -   **RestartPolicy** – The behavior to apply when the container exits.  The
   260              value is an object with a `Name` property of either `"always"` to
   261              always restart or `"on-failure"` to restart only when the container
   262              exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   263              controls the number of times to retry before giving up.
   264              The default is not to restart. (optional)
   265              An ever increasing delay (double the previous delay, starting at 100mS)
   266              is added before each restart to prevent flooding the server.
   267      -   **NetworkMode** - Sets the networking mode for the container. Supported
   268            values are: `bridge`, `host`, and `container:<name|id>`
   269      -   **Devices** - A list of devices to add to the container specified as a JSON object in the
   270        form
   271            `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   272      -   **Ulimits** - A list of ulimits to set in the container, specified as
   273            `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   274            `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard", 2048 }}`
   275      -   **SecurityOpt**: A list of string values to customize labels for MLS
   276          systems, such as SELinux.
   277      -   **LogConfig** - Log configuration for the container, specified as a JSON object in the form
   278            `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   279            Available types: `json-file`, `syslog`, `journald`, `gelf`, `none`.
   280            `json-file` logging driver.
   281      -   **CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
   282  
   283  Query Parameters:
   284  
   285  -   **name** – Assign the specified name to the container. Must
   286      match `/?[a-zA-Z0-9_-]+`.
   287  
   288  Status Codes:
   289  
   290  -   **201** – no error
   291  -   **404** – no such container
   292  -   **406** – impossible to attach (container not running)
   293  -   **500** – server error
   294  
   295  ### Inspect a container
   296  
   297  `GET /containers/(id)/json`
   298  
   299  Return low-level information on the container `id`
   300  
   301  
   302  **Example request**:
   303  
   304        GET /containers/4fa6e0f0c678/json HTTP/1.1
   305  
   306  **Example response**:
   307  
   308      HTTP/1.1 200 OK
   309      Content-Type: application/json
   310  
   311      {
   312  		"AppArmorProfile": "",
   313  		"Args": [
   314  			"-c",
   315  			"exit 9"
   316  		],
   317  		"Config": {
   318  			"AttachStderr": true,
   319  			"AttachStdin": false,
   320  			"AttachStdout": true,
   321  			"Cmd": [
   322  				"/bin/sh",
   323  				"-c",
   324  				"exit 9"
   325  			],
   326  			"Domainname": "",
   327  			"Entrypoint": null,
   328  			"Env": [
   329  				"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   330  			],
   331  			"ExposedPorts": null,
   332  			"Hostname": "ba033ac44011",
   333  			"Image": "ubuntu",
   334  			"Labels": {
   335  				"com.example.vendor": "Acme",
   336  				"com.example.license": "GPL",
   337  				"com.example.version": "1.0"
   338  			},
   339  			"MacAddress": "",
   340  			"NetworkDisabled": false,
   341  			"OnBuild": null,
   342  			"OpenStdin": false,
   343  			"StdinOnce": false,
   344  			"Tty": false,
   345  			"User": "",
   346  			"Volumes": null,
   347  			"WorkingDir": ""
   348  		},
   349  		"Created": "2015-01-06T15:47:31.485331387Z",
   350  		"Driver": "devicemapper",
   351  		"ExecDriver": "native-0.2",
   352  		"ExecIDs": null,
   353  		"HostConfig": {
   354  			"Binds": null,
   355  			"BlkioWeight": 0,
   356  			"CapAdd": null,
   357  			"CapDrop": null,
   358  			"ContainerIDFile": "",
   359  			"CpusetCpus": "",
   360  			"CpusetMems": "",
   361  			"CpuShares": 0,
   362  			"CpuPeriod": 100000,
   363  			"Devices": [],
   364  			"Dns": null,
   365  			"DnsSearch": null,
   366  			"ExtraHosts": null,
   367  			"IpcMode": "",
   368  			"Links": null,
   369  			"LxcConf": [],
   370  			"Memory": 0,
   371  			"MemorySwap": 0,
   372  			"OomKillDisable": false,
   373  			"NetworkMode": "bridge",
   374  			"PortBindings": {},
   375  			"Privileged": false,
   376  			"ReadonlyRootfs": false,
   377  			"PublishAllPorts": false,
   378  			"RestartPolicy": {
   379  				"MaximumRetryCount": 2,
   380  				"Name": "on-failure"
   381  			},
   382  			"LogConfig": {
   383  				"Config": null,
   384  				"Type": "json-file"
   385  			},
   386  			"SecurityOpt": null,
   387  			"VolumesFrom": null,
   388  			"Ulimits": [{}]
   389  		},
   390  		"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
   391  		"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
   392  		"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
   393  		"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
   394  		"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
   395  		"MountLabel": "",
   396  		"Name": "/boring_euclid",
   397  		"NetworkSettings": {
   398  			"Bridge": "",
   399  			"Gateway": "",
   400  			"IPAddress": "",
   401  			"IPPrefixLen": 0,
   402  			"MacAddress": "",
   403  			"PortMapping": null,
   404  			"Ports": null
   405  		},
   406  		"Path": "/bin/sh",
   407  		"ProcessLabel": "",
   408  		"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
   409  		"RestartCount": 1,
   410  		"State": {
   411  			"Error": "",
   412  			"ExitCode": 9,
   413  			"FinishedAt": "2015-01-06T15:47:32.080254511Z",
   414  			"OOMKilled": false,
   415  			"Paused": false,
   416  			"Pid": 0,
   417  			"Restarting": false,
   418  			"Running": false,
   419  			"StartedAt": "2015-01-06T15:47:32.072697474Z"
   420  		},
   421  		"Volumes": {},
   422  		"VolumesRW": {}
   423  	}
   424  
   425  Status Codes:
   426  
   427  -   **200** – no error
   428  -   **404** – no such container
   429  -   **500** – server error
   430  
   431  ### List processes running inside a container
   432  
   433  `GET /containers/(id)/top`
   434  
   435  List processes running inside the container `id`
   436  
   437  **Example request**:
   438  
   439      GET /containers/4fa6e0f0c678/top HTTP/1.1
   440  
   441  **Example response**:
   442  
   443      HTTP/1.1 200 OK
   444      Content-Type: application/json
   445  
   446      {
   447           "Titles": [
   448                   "USER",
   449                   "PID",
   450                   "%CPU",
   451                   "%MEM",
   452                   "VSZ",
   453                   "RSS",
   454                   "TTY",
   455                   "STAT",
   456                   "START",
   457                   "TIME",
   458                   "COMMAND"
   459                   ],
   460           "Processes": [
   461                   ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   462                   ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   463           ]
   464      }
   465  
   466  Query Parameters:
   467  
   468  -   **ps_args** – ps arguments to use (e.g., aux)
   469  
   470  Status Codes:
   471  
   472  -   **200** – no error
   473  -   **404** – no such container
   474  -   **500** – server error
   475  
   476  ### Get container logs
   477  
   478  `GET /containers/(id)/logs`
   479  
   480  Get `stdout` and `stderr` logs from the container ``id``
   481  
   482  > **Note**:
   483  > This endpoint works only for containers with `json-file` logging driver.
   484  
   485  **Example request**:
   486  
   487       GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1
   488  
   489  **Example response**:
   490  
   491       HTTP/1.1 101 UPGRADED
   492       Content-Type: application/vnd.docker.raw-stream
   493       Connection: Upgrade
   494       Upgrade: tcp
   495  
   496       {{ STREAM }}
   497  
   498  Query Parameters:
   499  
   500  -   **follow** – 1/True/true or 0/False/false, return stream. Default `false`.
   501  -   **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`.
   502  -   **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`.
   503  -   **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
   504      will only output log-entries since that timestamp. Default: 0 (unfiltered)
   505  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   506          every log line. Default `false`.
   507  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
   508  
   509  Status Codes:
   510  
   511  -   **101** – no error, hints proxy about hijacking
   512  -   **200** – no error, no upgrade header found
   513  -   **404** – no such container
   514  -   **500** – server error
   515  
   516  ### Inspect changes on a container's filesystem
   517  
   518  `GET /containers/(id)/changes`
   519  
   520  Inspect changes on container `id`'s filesystem
   521  
   522  **Example request**:
   523  
   524      GET /containers/4fa6e0f0c678/changes HTTP/1.1
   525  
   526  **Example response**:
   527  
   528      HTTP/1.1 200 OK
   529      Content-Type: application/json
   530  
   531      [
   532           {
   533                   "Path": "/dev",
   534                   "Kind": 0
   535           },
   536           {
   537                   "Path": "/dev/kmsg",
   538                   "Kind": 1
   539           },
   540           {
   541                   "Path": "/test",
   542                   "Kind": 1
   543           }
   544      ]
   545  
   546  Values for `Kind`:
   547  
   548  - `0`: Modify
   549  - `1`: Add
   550  - `2`: Delete
   551  
   552  Status Codes:
   553  
   554  -   **200** – no error
   555  -   **404** – no such container
   556  -   **500** – server error
   557  
   558  ### Export a container
   559  
   560  `GET /containers/(id)/export`
   561  
   562  Export the contents of container `id`
   563  
   564  **Example request**:
   565  
   566      GET /containers/4fa6e0f0c678/export HTTP/1.1
   567  
   568  **Example response**:
   569  
   570      HTTP/1.1 200 OK
   571      Content-Type: application/octet-stream
   572  
   573      {{ TAR STREAM }}
   574  
   575  Status Codes:
   576  
   577  -   **200** – no error
   578  -   **404** – no such container
   579  -   **500** – server error
   580  
   581  ### Get container stats based on resource usage
   582  
   583  `GET /containers/(id)/stats`
   584  
   585  This endpoint returns a live stream of a container's resource usage statistics.
   586  
   587  > **Note**: this functionality currently only works when using the *libcontainer* exec-driver.
   588  
   589  **Example request**:
   590  
   591      GET /containers/redis1/stats HTTP/1.1
   592  
   593  **Example response**:
   594  
   595        HTTP/1.1 200 OK
   596        Content-Type: application/json
   597  
   598        {
   599           "read" : "2015-01-08T22:57:31.547920715Z",
   600           "network" : {
   601              "rx_dropped" : 0,
   602              "rx_bytes" : 648,
   603              "rx_errors" : 0,
   604              "tx_packets" : 8,
   605              "tx_dropped" : 0,
   606              "rx_packets" : 8,
   607              "tx_errors" : 0,
   608              "tx_bytes" : 648
   609           },
   610           "memory_stats" : {
   611              "stats" : {
   612                 "total_pgmajfault" : 0,
   613                 "cache" : 0,
   614                 "mapped_file" : 0,
   615                 "total_inactive_file" : 0,
   616                 "pgpgout" : 414,
   617                 "rss" : 6537216,
   618                 "total_mapped_file" : 0,
   619                 "writeback" : 0,
   620                 "unevictable" : 0,
   621                 "pgpgin" : 477,
   622                 "total_unevictable" : 0,
   623                 "pgmajfault" : 0,
   624                 "total_rss" : 6537216,
   625                 "total_rss_huge" : 6291456,
   626                 "total_writeback" : 0,
   627                 "total_inactive_anon" : 0,
   628                 "rss_huge" : 6291456,
   629                 "hierarchical_memory_limit" : 67108864,
   630                 "total_pgfault" : 964,
   631                 "total_active_file" : 0,
   632                 "active_anon" : 6537216,
   633                 "total_active_anon" : 6537216,
   634                 "total_pgpgout" : 414,
   635                 "total_cache" : 0,
   636                 "inactive_anon" : 0,
   637                 "active_file" : 0,
   638                 "pgfault" : 964,
   639                 "inactive_file" : 0,
   640                 "total_pgpgin" : 477
   641              },
   642              "max_usage" : 6651904,
   643              "usage" : 6537216,
   644              "failcnt" : 0,
   645              "limit" : 67108864
   646           },
   647           "blkio_stats" : {},
   648           "cpu_stats" : {
   649              "cpu_usage" : {
   650                 "percpu_usage" : [
   651                    16970827,
   652                    1839451,
   653                    7107380,
   654                    10571290
   655                 ],
   656                 "usage_in_usermode" : 10000000,
   657                 "total_usage" : 36488948,
   658                 "usage_in_kernelmode" : 20000000
   659              },
   660              "system_cpu_usage" : 20091722000000000,
   661              "throttling_data" : {}
   662           }
   663        }
   664  
   665  Query Parameters:
   666  
   667  -   **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
   668  
   669  Status Codes:
   670  
   671  -   **200** – no error
   672  -   **404** – no such container
   673  -   **500** – server error
   674  
   675  ### Resize a container TTY
   676  
   677  `POST /containers/(id)/resize?h=<height>&w=<width>`
   678  
   679  Resize the TTY for container with  `id`. You must restart the container for the resize to take effect.
   680  
   681  **Example request**:
   682  
   683        POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   684  
   685  **Example response**:
   686  
   687        HTTP/1.1 200 OK
   688        Content-Length: 0
   689        Content-Type: text/plain; charset=utf-8
   690  
   691  Status Codes:
   692  
   693  -   **200** – no error
   694  -   **404** – No such container
   695  -   **500** – Cannot resize container
   696  
   697  ### Start a container
   698  
   699  `POST /containers/(id)/start`
   700  
   701  Start the container `id`
   702  
   703  > **Note**:
   704  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   705  > See [create a container](#create-a-container) for details.
   706  
   707  **Example request**:
   708  
   709      POST /containers/(id)/start HTTP/1.1
   710  
   711  **Example response**:
   712  
   713      HTTP/1.1 204 No Content
   714  
   715  Status Codes:
   716  
   717  -   **204** – no error
   718  -   **304** – container already started
   719  -   **404** – no such container
   720  -   **500** – server error
   721  
   722  ### Stop a container
   723  
   724  `POST /containers/(id)/stop`
   725  
   726  Stop the container `id`
   727  
   728  **Example request**:
   729  
   730      POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   731  
   732  **Example response**:
   733  
   734      HTTP/1.1 204 No Content
   735  
   736  Query Parameters:
   737  
   738  -   **t** – number of seconds to wait before killing the container
   739  
   740  Status Codes:
   741  
   742  -   **204** – no error
   743  -   **304** – container already stopped
   744  -   **404** – no such container
   745  -   **500** – server error
   746  
   747  ### Restart a container
   748  
   749  `POST /containers/(id)/restart`
   750  
   751  Restart the container `id`
   752  
   753  **Example request**:
   754  
   755      POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   756  
   757  **Example response**:
   758  
   759      HTTP/1.1 204 No Content
   760  
   761  Query Parameters:
   762  
   763  -   **t** – number of seconds to wait before killing the container
   764  
   765  Status Codes:
   766  
   767  -   **204** – no error
   768  -   **404** – no such container
   769  -   **500** – server error
   770  
   771  ### Kill a container
   772  
   773  `POST /containers/(id)/kill`
   774  
   775  Kill the container `id`
   776  
   777  **Example request**:
   778  
   779      POST /containers/e90e34656806/kill HTTP/1.1
   780  
   781  **Example response**:
   782  
   783      HTTP/1.1 204 No Content
   784  
   785  Query Parameters
   786  
   787  -   **signal** - Signal to send to the container: integer or string like `SIGINT`.
   788          When not set, `SIGKILL` is assumed and the call waits for the container to exit.
   789  
   790  Status Codes:
   791  
   792  -   **204** – no error
   793  -   **404** – no such container
   794  -   **500** – server error
   795  
   796  ### Rename a container
   797  
   798  `POST /containers/(id)/rename`
   799  
   800  Rename the container `id` to a `new_name`
   801  
   802  **Example request**:
   803  
   804      POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
   805  
   806  **Example response**:
   807  
   808      HTTP/1.1 204 No Content
   809  
   810  Query Parameters:
   811  
   812  -   **name** – new name for the container
   813  
   814  Status Codes:
   815  
   816  -   **204** – no error
   817  -   **404** – no such container
   818  -   **409** - conflict name already assigned
   819  -   **500** – server error
   820  
   821  ### Pause a container
   822  
   823  `POST /containers/(id)/pause`
   824  
   825  Pause the container `id`
   826  
   827  **Example request**:
   828  
   829      POST /containers/e90e34656806/pause HTTP/1.1
   830  
   831  **Example response**:
   832  
   833      HTTP/1.1 204 No Content
   834  
   835  Status Codes:
   836  
   837  -   **204** – no error
   838  -   **404** – no such container
   839  -   **500** – server error
   840  
   841  ### Unpause a container
   842  
   843  `POST /containers/(id)/unpause`
   844  
   845  Unpause the container `id`
   846  
   847  **Example request**:
   848  
   849      POST /containers/e90e34656806/unpause HTTP/1.1
   850  
   851  **Example response**:
   852  
   853      HTTP/1.1 204 No Content
   854  
   855  Status Codes:
   856  
   857  -   **204** – no error
   858  -   **404** – no such container
   859  -   **500** – server error
   860  
   861  ### Attach to a container
   862  
   863  `POST /containers/(id)/attach`
   864  
   865  Attach to the container `id`
   866  
   867  **Example request**:
   868  
   869      POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   870  
   871  **Example response**:
   872  
   873      HTTP/1.1 101 UPGRADED
   874      Content-Type: application/vnd.docker.raw-stream
   875      Connection: Upgrade
   876      Upgrade: tcp
   877  
   878      {{ STREAM }}
   879  
   880  Query Parameters:
   881  
   882  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
   883  -   **stream** – 1/True/true or 0/False/false, return stream.
   884          Default `false`.
   885  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
   886          to `stdin`. Default `false`.
   887  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
   888          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
   889  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
   890          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
   891  
   892  Status Codes:
   893  
   894  -   **101** – no error, hints proxy about hijacking
   895  -   **200** – no error, no upgrade header found
   896  -   **400** – bad parameter
   897  -   **404** – no such container
   898  -   **500** – server error
   899  
   900      **Stream details**:
   901  
   902      When using the TTY setting is enabled in
   903      [`POST /containers/create`
   904      ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
   905      the stream is the raw data from the process PTY and client's `stdin`.
   906      When the TTY is disabled, then the stream is multiplexed to separate
   907      `stdout` and `stderr`.
   908  
   909      The format is a **Header** and a **Payload** (frame).
   910  
   911      **HEADER**
   912  
   913      The header contains the information which the stream writes (`stdout` or
   914      `stderr`). It also contains the size of the associated frame encoded in the
   915      last four bytes (`uint32`).
   916  
   917      It is encoded on the first eight bytes like this:
   918  
   919          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   920  
   921      `STREAM_TYPE` can be:
   922  
   923  -   0: `stdin` (is written on `stdout`)
   924  -   1: `stdout`
   925  -   2: `stderr`
   926  
   927      `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
   928      the `uint32` size encoded as big endian.
   929  
   930      **PAYLOAD**
   931  
   932      The payload is the raw stream.
   933  
   934      **IMPLEMENTATION**
   935  
   936      The simplest way to implement the Attach protocol is the following:
   937  
   938      1.  Read eight bytes.
   939      2.  Choose `stdout` or `stderr` depending on the first byte.
   940      3.  Extract the frame size from the last four bytes.
   941      4.  Read the extracted size and output it on the correct output.
   942      5.  Goto 1.
   943  
   944  ### Attach to a container (websocket)
   945  
   946  `GET /containers/(id)/attach/ws`
   947  
   948  Attach to the container `id` via websocket
   949  
   950  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   951  
   952  **Example request**
   953  
   954      GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   955  
   956  **Example response**
   957  
   958      {{ STREAM }}
   959  
   960  Query Parameters:
   961  
   962  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
   963  -   **stream** – 1/True/true or 0/False/false, return stream.
   964          Default `false`.
   965  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
   966          to `stdin`. Default `false`.
   967  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
   968          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
   969  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
   970          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
   971  
   972  Status Codes:
   973  
   974  -   **200** – no error
   975  -   **400** – bad parameter
   976  -   **404** – no such container
   977  -   **500** – server error
   978  
   979  ### Wait a container
   980  
   981  `POST /containers/(id)/wait`
   982  
   983  Block until container `id` stops, then returns the exit code
   984  
   985  **Example request**:
   986  
   987      POST /containers/16253994b7c4/wait HTTP/1.1
   988  
   989  **Example response**:
   990  
   991      HTTP/1.1 200 OK
   992      Content-Type: application/json
   993  
   994      {"StatusCode": 0}
   995  
   996  Status Codes:
   997  
   998  -   **200** – no error
   999  -   **404** – no such container
  1000  -   **500** – server error
  1001  
  1002  ### Remove a container
  1003  
  1004  `DELETE /containers/(id)`
  1005  
  1006  Remove the container `id` from the filesystem
  1007  
  1008  **Example request**:
  1009  
  1010      DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  1011  
  1012  **Example response**:
  1013  
  1014      HTTP/1.1 204 No Content
  1015  
  1016  Query Parameters:
  1017  
  1018  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1019          associated to the container. Default `false`.
  1020  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1021          Default `false`.
  1022  
  1023  Status Codes:
  1024  
  1025  -   **204** – no error
  1026  -   **400** – bad parameter
  1027  -   **404** – no such container
  1028  -   **500** – server error
  1029  
  1030  ### Copy files or folders from a container
  1031  
  1032  `POST /containers/(id)/copy`
  1033  
  1034  Copy files or folders of container `id`
  1035  
  1036  **Example request**:
  1037  
  1038      POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1039      Content-Type: application/json
  1040  
  1041      {
  1042           "Resource": "test.txt"
  1043      }
  1044  
  1045  **Example response**:
  1046  
  1047      HTTP/1.1 200 OK
  1048      Content-Type: application/x-tar
  1049  
  1050      {{ TAR STREAM }}
  1051  
  1052  Status Codes:
  1053  
  1054  -   **200** – no error
  1055  -   **404** – no such container
  1056  -   **500** – server error
  1057  
  1058  ## 2.2 Images
  1059  
  1060  ### List Images
  1061  
  1062  `GET /images/json`
  1063  
  1064  **Example request**:
  1065  
  1066      GET /images/json?all=0 HTTP/1.1
  1067  
  1068  **Example response**:
  1069  
  1070      HTTP/1.1 200 OK
  1071      Content-Type: application/json
  1072  
  1073      [
  1074        {
  1075           "RepoTags": [
  1076             "ubuntu:12.04",
  1077             "ubuntu:precise",
  1078             "ubuntu:latest"
  1079           ],
  1080           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1081           "Created": 1365714795,
  1082           "Size": 131506275,
  1083           "VirtualSize": 131506275
  1084        },
  1085        {
  1086           "RepoTags": [
  1087             "ubuntu:12.10",
  1088             "ubuntu:quantal"
  1089           ],
  1090           "ParentId": "27cf784147099545",
  1091           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1092           "Created": 1364102658,
  1093           "Size": 24653,
  1094           "VirtualSize": 180116135
  1095        }
  1096      ]
  1097  
  1098  **Example request, with digest information**:
  1099  
  1100      GET /images/json?digests=1 HTTP/1.1
  1101  
  1102  **Example response, with digest information**:
  1103  
  1104      HTTP/1.1 200 OK
  1105      Content-Type: application/json
  1106  
  1107      [
  1108        {
  1109          "Created": 1420064636,
  1110          "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1111          "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1112          "RepoDigests": [
  1113            "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1114          ],
  1115          "RepoTags": [
  1116            "localhost:5000/test/busybox:latest",
  1117            "playdate:latest"
  1118          ],
  1119          "Size": 0,
  1120          "VirtualSize": 2429728
  1121        }
  1122      ]
  1123  
  1124  The response shows a single image `Id` associated with two repositories
  1125  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1126  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1127  `playdate:latest` to reference the image.
  1128  
  1129  You can also use `RepoDigests` values to reference an image. In this response,
  1130  the array has only one reference and that is to the
  1131  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1132  digest. You can reference this digest using the value:
  1133  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1134  
  1135  See the `docker run` and `docker build` commands for examples of digest and tag
  1136  references on the command line.
  1137  
  1138  Query Parameters:
  1139  
  1140  -   **all** – 1/True/true or 0/False/false, default false
  1141  -   **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1142    -   `dangling=true`
  1143    -   `label=key` or `key=value` of an image label
  1144  
  1145  ### Build image from a Dockerfile
  1146  
  1147  `POST /build`
  1148  
  1149  Build an image from a Dockerfile
  1150  
  1151  **Example request**:
  1152  
  1153      POST /build HTTP/1.1
  1154  
  1155      {{ TAR STREAM }}
  1156  
  1157  **Example response**:
  1158  
  1159      HTTP/1.1 200 OK
  1160      Content-Type: application/json
  1161  
  1162      {"stream": "Step 1..."}
  1163      {"stream": "..."}
  1164      {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1165  
  1166  The input stream must be a `tar` archive compressed with one of the
  1167  following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
  1168  
  1169  The archive must include a build instructions file, typically called
  1170  `Dockerfile` at the archive's root. The `dockerfile` parameter may be
  1171  used to specify a different build instructions file. To do this, its value must be
  1172  the path to the alternate build instructions file to use.
  1173  
  1174  The archive may include any number of other files,
  1175  which are accessible in the build context (See the [*ADD build
  1176  command*](/reference/builder/#dockerbuilder)).
  1177  
  1178  The build is canceled if the client drops the connection by quitting
  1179  or being killed.
  1180  
  1181  Query Parameters:
  1182  
  1183  -   **dockerfile** - Path within the build context to the Dockerfile. This is 
  1184          ignored if `remote` is specified and points to an individual filename.
  1185  -   **t** – A repository name (and optionally a tag) to apply to
  1186          the resulting image in case of success.
  1187  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 
  1188          URI specifies a filename, the file's contents are placed into a file 
  1189  		called `Dockerfile`.
  1190  -   **q** – Suppress verbose build output.
  1191  -   **nocache** – Do not use the cache when building the image.
  1192  -   **pull** - Attempt to pull the image even if an older image exists locally.
  1193  -   **rm** - Remove intermediate containers after a successful build (default behavior).
  1194  -   **forcerm** - Always remove intermediate containers (includes `rm`).
  1195  -   **memory** - Set memory limit for build.
  1196  -   **memswap** - Total memory (memory + swap), `-1` to disable swap.
  1197  -   **cpushares** - CPU shares (relative weight).
  1198  -   **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
  1199  
  1200      Request Headers:
  1201  
  1202  -   **Content-type** – Set to `"application/tar"`.
  1203  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1204  
  1205  Status Codes:
  1206  
  1207  -   **200** – no error
  1208  -   **500** – server error
  1209  
  1210  ### Create an image
  1211  
  1212  `POST /images/create`
  1213  
  1214  Create an image either by pulling it from the registry or by importing it
  1215  
  1216  **Example request**:
  1217  
  1218      POST /images/create?fromImage=ubuntu HTTP/1.1
  1219  
  1220  **Example response**:
  1221  
  1222      HTTP/1.1 200 OK
  1223      Content-Type: application/json
  1224  
  1225      {"status": "Pulling..."}
  1226      {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1227      {"error": "Invalid..."}
  1228      ...
  1229  
  1230  When using this endpoint to pull an image from the registry, the
  1231  `X-Registry-Auth` header can be used to include
  1232  a base64-encoded AuthConfig object.
  1233  
  1234  Query Parameters:
  1235  
  1236  -   **fromImage** – Name of the image to pull.
  1237  -   **fromSrc** – Source to import.  The value may be a URL from which the image
  1238          can be retrieved or `-` to read the image from the request body.
  1239  -   **repo** – Repository name.
  1240  -   **tag** – Tag.
  1241  -   **registry** – The registry to pull from.
  1242  
  1243      Request Headers:
  1244  
  1245  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1246  
  1247  Status Codes:
  1248  
  1249  -   **200** – no error
  1250  -   **500** – server error
  1251  
  1252  
  1253  
  1254  ### Inspect an image
  1255  
  1256  `GET /images/(name)/json`
  1257  
  1258  Return low-level information on the image `name`
  1259  
  1260  **Example request**:
  1261  
  1262      GET /images/ubuntu/json HTTP/1.1
  1263  
  1264  **Example response**:
  1265  
  1266      HTTP/1.1 200 OK
  1267      Content-Type: application/json
  1268  
  1269      {
  1270           "Created": "2013-03-23T22:24:18.818426-07:00",
  1271           "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1272           "ContainerConfig":
  1273                   {
  1274                           "Hostname": "",
  1275                           "User": "",
  1276                           "AttachStdin": false,
  1277                           "AttachStdout": false,
  1278                           "AttachStderr": false,
  1279                           "Tty": true,
  1280                           "OpenStdin": true,
  1281                           "StdinOnce": false,
  1282                           "Env": null,
  1283                           "Cmd": ["/bin/bash"],
  1284                           "Dns": null,
  1285                           "Image": "ubuntu",
  1286                           "Labels": {
  1287                               "com.example.vendor": "Acme",
  1288                               "com.example.license": "GPL",
  1289                               "com.example.version": "1.0"
  1290                           },
  1291                           "Volumes": null,
  1292                           "VolumesFrom": "",
  1293                           "WorkingDir": ""
  1294                   },
  1295           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1296           "Parent": "27cf784147099545",
  1297           "Size": 6824592
  1298      }
  1299  
  1300  Status Codes:
  1301  
  1302  -   **200** – no error
  1303  -   **404** – no such image
  1304  -   **500** – server error
  1305  
  1306  ### Get the history of an image
  1307  
  1308  `GET /images/(name)/history`
  1309  
  1310  Return the history of the image `name`
  1311  
  1312  **Example request**:
  1313  
  1314      GET /images/ubuntu/history HTTP/1.1
  1315  
  1316  **Example response**:
  1317  
  1318      HTTP/1.1 200 OK
  1319      Content-Type: application/json
  1320  
  1321      [
  1322           {
  1323                   "Id": "b750fe79269d",
  1324                   "Created": 1364102658,
  1325                   "CreatedBy": "/bin/bash"
  1326           },
  1327           {
  1328                   "Id": "27cf78414709",
  1329                   "Created": 1364068391,
  1330                   "CreatedBy": ""
  1331           }
  1332      ]
  1333  
  1334  Status Codes:
  1335  
  1336  -   **200** – no error
  1337  -   **404** – no such image
  1338  -   **500** – server error
  1339  
  1340  ### Push an image on the registry
  1341  
  1342  `POST /images/(name)/push`
  1343  
  1344  Push the image `name` on the registry
  1345  
  1346  **Example request**:
  1347  
  1348      POST /images/test/push HTTP/1.1
  1349  
  1350  **Example response**:
  1351  
  1352      HTTP/1.1 200 OK
  1353      Content-Type: application/json
  1354  
  1355      {"status": "Pushing..."}
  1356      {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1357      {"error": "Invalid..."}
  1358      ...
  1359  
  1360  If you wish to push an image on to a private registry, that image must already have a tag
  1361  into a repository which references that registry `hostname` and `port`.  This repository name should
  1362  then be used in the URL. This duplicates the command line's flow.
  1363  
  1364  **Example request**:
  1365  
  1366      POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1367  
  1368  
  1369  Query Parameters:
  1370  
  1371  -   **tag** – The tag to associate with the image on the registry. This is optional.
  1372  
  1373  Request Headers:
  1374  
  1375  -   **X-Registry-Auth** – Include a base64-encoded AuthConfig.
  1376          object.
  1377  
  1378  Status Codes:
  1379  
  1380  -   **200** – no error
  1381  -   **404** – no such image
  1382  -   **500** – server error
  1383  
  1384  ### Tag an image into a repository
  1385  
  1386  `POST /images/(name)/tag`
  1387  
  1388  Tag the image `name` into a repository
  1389  
  1390  **Example request**:
  1391  
  1392      POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1393  
  1394  **Example response**:
  1395  
  1396      HTTP/1.1 201 OK
  1397  
  1398  Query Parameters:
  1399  
  1400  -   **repo** – The repository to tag in
  1401  -   **force** – 1/True/true or 0/False/false, default false
  1402  -   **tag** - The new tag name
  1403  
  1404  Status Codes:
  1405  
  1406  -   **201** – no error
  1407  -   **400** – bad parameter
  1408  -   **404** – no such image
  1409  -   **409** – conflict
  1410  -   **500** – server error
  1411  
  1412  ### Remove an image
  1413  
  1414  `DELETE /images/(name)`
  1415  
  1416  Remove the image `name` from the filesystem
  1417  
  1418  **Example request**:
  1419  
  1420      DELETE /images/test HTTP/1.1
  1421  
  1422  **Example response**:
  1423  
  1424      HTTP/1.1 200 OK
  1425      Content-type: application/json
  1426  
  1427      [
  1428       {"Untagged": "3e2f21a89f"},
  1429       {"Deleted": "3e2f21a89f"},
  1430       {"Deleted": "53b4f83ac9"}
  1431      ]
  1432  
  1433  Query Parameters:
  1434  
  1435  -   **force** – 1/True/true or 0/False/false, default false
  1436  -   **noprune** – 1/True/true or 0/False/false, default false
  1437  
  1438  Status Codes:
  1439  
  1440  -   **200** – no error
  1441  -   **404** – no such image
  1442  -   **409** – conflict
  1443  -   **500** – server error
  1444  
  1445  ### Search images
  1446  
  1447  `GET /images/search`
  1448  
  1449  Search for an image on [Docker Hub](https://hub.docker.com).
  1450  
  1451  > **Note**:
  1452  > The response keys have changed from API v1.6 to reflect the JSON
  1453  > sent by the registry server to the docker daemon's request.
  1454  
  1455  **Example request**:
  1456  
  1457      GET /images/search?term=sshd HTTP/1.1
  1458  
  1459  **Example response**:
  1460  
  1461      HTTP/1.1 200 OK
  1462      Content-Type: application/json
  1463  
  1464      [
  1465              {
  1466                  "description": "",
  1467                  "is_official": false,
  1468                  "is_automated": false,
  1469                  "name": "wma55/u1210sshd",
  1470                  "star_count": 0
  1471              },
  1472              {
  1473                  "description": "",
  1474                  "is_official": false,
  1475                  "is_automated": false,
  1476                  "name": "jdswinbank/sshd",
  1477                  "star_count": 0
  1478              },
  1479              {
  1480                  "description": "",
  1481                  "is_official": false,
  1482                  "is_automated": false,
  1483                  "name": "vgauthier/sshd",
  1484                  "star_count": 0
  1485              }
  1486      ...
  1487      ]
  1488  
  1489  Query Parameters:
  1490  
  1491  -   **term** – term to search
  1492  
  1493  Status Codes:
  1494  
  1495  -   **200** – no error
  1496  -   **500** – server error
  1497  
  1498  ## 2.3 Misc
  1499  
  1500  ### Check auth configuration
  1501  
  1502  `POST /auth`
  1503  
  1504  Get the default username and email
  1505  
  1506  **Example request**:
  1507  
  1508      POST /auth HTTP/1.1
  1509      Content-Type: application/json
  1510  
  1511      {
  1512           "username":" hannibal",
  1513           "password: "xxxx",
  1514           "email": "hannibal@a-team.com",
  1515           "serveraddress": "https://index.docker.io/v1/"
  1516      }
  1517  
  1518  **Example response**:
  1519  
  1520      HTTP/1.1 200 OK
  1521  
  1522  Status Codes:
  1523  
  1524  -   **200** – no error
  1525  -   **204** – no error
  1526  -   **500** – server error
  1527  
  1528  ### Display system-wide information
  1529  
  1530  `GET /info`
  1531  
  1532  Display system-wide information
  1533  
  1534  **Example request**:
  1535  
  1536      GET /info HTTP/1.1
  1537  
  1538  **Example response**:
  1539  
  1540      HTTP/1.1 200 OK
  1541      Content-Type: application/json
  1542  
  1543      {
  1544          "Containers": 11,
  1545          "CpuCfsPeriod": true,
  1546          "CpuCfsQuota": true,
  1547          "Debug": false,
  1548          "DockerRootDir": "/var/lib/docker",
  1549          "Driver": "btrfs",
  1550          "DriverStatus": [[""]],
  1551          "ExecutionDriver": "native-0.1",
  1552          "ExperimentalBuild": false,
  1553          "HttpProxy": "http://test:test@localhost:8080",
  1554          "HttpsProxy": "https://test:test@localhost:8080",
  1555          "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1556          "IPv4Forwarding": true,
  1557          "Images": 16,
  1558          "IndexServerAddress": "https://index.docker.io/v1/",
  1559          "InitPath": "/usr/bin/docker",
  1560          "InitSha1": "",
  1561          "KernelVersion": "3.12.0-1-amd64",
  1562          "Labels": [
  1563              "storage=ssd"
  1564          ],
  1565          "MemTotal": 2099236864,
  1566          "MemoryLimit": true,
  1567          "NCPU": 1,
  1568          "NEventsListener": 0,
  1569          "NFd": 11,
  1570          "NGoroutines": 21,
  1571          "Name": "prod-server-42",
  1572          "NoProxy": "9.81.1.160",
  1573          "OomKillDisable": true,
  1574          "OperatingSystem": "Boot2Docker",
  1575          "RegistryConfig": {
  1576              "IndexConfigs": {
  1577                  "docker.io": {
  1578                      "Mirrors": null,
  1579                      "Name": "docker.io",
  1580                      "Official": true,
  1581                      "Secure": true
  1582                  }
  1583              },
  1584              "InsecureRegistryCIDRs": [
  1585                  "127.0.0.0/8"
  1586              ]
  1587          },
  1588          "SwapLimit": false,
  1589          "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1590      }
  1591  
  1592  Status Codes:
  1593  
  1594  -   **200** – no error
  1595  -   **500** – server error
  1596  
  1597  ### Show the docker version information
  1598  
  1599  `GET /version`
  1600  
  1601  Show the docker version information
  1602  
  1603  **Example request**:
  1604  
  1605      GET /version HTTP/1.1
  1606  
  1607  **Example response**:
  1608  
  1609      HTTP/1.1 200 OK
  1610      Content-Type: application/json
  1611  
  1612      {
  1613           "Version": "1.5.0",
  1614           "Os": "linux",
  1615           "KernelVersion": "3.18.5-tinycore64",
  1616           "GoVersion": "go1.4.1",
  1617           "GitCommit": "a8a31ef",
  1618           "Arch": "amd64",
  1619           "ApiVersion": "1.20",
  1620           "Experimental": false
  1621      }
  1622  
  1623  Status Codes:
  1624  
  1625  -   **200** – no error
  1626  -   **500** – server error
  1627  
  1628  ### Ping the docker server
  1629  
  1630  `GET /_ping`
  1631  
  1632  Ping the docker server
  1633  
  1634  **Example request**:
  1635  
  1636      GET /_ping HTTP/1.1
  1637  
  1638  **Example response**:
  1639  
  1640      HTTP/1.1 200 OK
  1641      Content-Type: text/plain
  1642  
  1643      OK
  1644  
  1645  Status Codes:
  1646  
  1647  -   **200** - no error
  1648  -   **500** - server error
  1649  
  1650  ### Create a new image from a container's changes
  1651  
  1652  `POST /commit`
  1653  
  1654  Create a new image from a container's changes
  1655  
  1656  **Example request**:
  1657  
  1658      POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1659      Content-Type: application/json
  1660  
  1661      {
  1662           "Hostname": "",
  1663           "Domainname": "",
  1664           "User": "",
  1665           "AttachStdin": false,
  1666           "AttachStdout": true,
  1667           "AttachStderr": true,
  1668           "Tty": false,
  1669           "OpenStdin": false,
  1670           "StdinOnce": false,
  1671           "Env": null,
  1672           "Cmd": [
  1673                   "date"
  1674           ],
  1675           "Volumes": {
  1676                   "/tmp": {}
  1677           },
  1678           "Labels": {
  1679                   "key1": "value1",
  1680                   "key2": "value2"
  1681            },
  1682           "WorkingDir": "",
  1683           "NetworkDisabled": false,
  1684           "ExposedPorts": {
  1685                   "22/tcp": {}
  1686           }
  1687      }
  1688  
  1689  **Example response**:
  1690  
  1691      HTTP/1.1 201 Created
  1692      Content-Type: application/vnd.docker.raw-stream
  1693  
  1694      {"Id": "596069db4bf5"}
  1695  
  1696  Json Parameters:
  1697  
  1698  -  **config** - the container's configuration
  1699  
  1700  Query Parameters:
  1701  
  1702  -   **container** – source container
  1703  -   **repo** – repository
  1704  -   **tag** – tag
  1705  -   **comment** – commit message
  1706  -   **author** – author (e.g., "John Hannibal Smith
  1707      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1708  
  1709  Status Codes:
  1710  
  1711  -   **201** – no error
  1712  -   **404** – no such container
  1713  -   **500** – server error
  1714  
  1715  ### Monitor Docker's events
  1716  
  1717  `GET /events`
  1718  
  1719  Get container events from docker, either in real time via streaming, or via
  1720  polling (using since).
  1721  
  1722  Docker containers report the following events:
  1723  
  1724      create, destroy, die, exec_create, exec_start, export, kill, oom, pause, restart, start, stop, unpause
  1725  
  1726  and Docker images report:
  1727  
  1728      untag, delete
  1729  
  1730  **Example request**:
  1731  
  1732      GET /events?since=1374067924
  1733  
  1734  **Example response**:
  1735  
  1736      HTTP/1.1 200 OK
  1737      Content-Type: application/json
  1738  
  1739      {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1740      {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1741      {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1742      {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1743  
  1744  Query Parameters:
  1745  
  1746  -   **since** – Timestamp used for polling
  1747  -   **until** – Timestamp used for polling
  1748  -   **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1749    -   `event=<string>`; -- event to filter
  1750    -   `image=<string>`; -- image to filter
  1751    -   `container=<string>`; -- container to filter
  1752  
  1753  Status Codes:
  1754  
  1755  -   **200** – no error
  1756  -   **500** – server error
  1757  
  1758  ### Get a tarball containing all images in a repository
  1759  
  1760  `GET /images/(name)/get`
  1761  
  1762  Get a tarball containing all images and metadata for the repository specified
  1763  by `name`.
  1764  
  1765  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1766  (and its parents) are returned. If `name` is an image ID, similarly only that
  1767  image (and its parents) are returned, but with the exclusion of the
  1768  'repositories' file in the tarball, as there were no image names referenced.
  1769  
  1770  See the [image tarball format](#image-tarball-format) for more details.
  1771  
  1772  **Example request**
  1773  
  1774      GET /images/ubuntu/get
  1775  
  1776  **Example response**:
  1777  
  1778      HTTP/1.1 200 OK
  1779      Content-Type: application/x-tar
  1780  
  1781      Binary data stream
  1782  
  1783  Status Codes:
  1784  
  1785  -   **200** – no error
  1786  -   **500** – server error
  1787  
  1788  ### Get a tarball containing all images.
  1789  
  1790  `GET /images/get`
  1791  
  1792  Get a tarball containing all images and metadata for one or more repositories.
  1793  
  1794  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1795  `ubuntu:latest`), then only that image (and its parents) are returned; if it is
  1796  an image ID, similarly only that image (and its parents) are returned and there
  1797  would be no names referenced in the 'repositories' file for this image ID.
  1798  
  1799  See the [image tarball format](#image-tarball-format) for more details.
  1800  
  1801  **Example request**
  1802  
  1803      GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1804  
  1805  **Example response**:
  1806  
  1807      HTTP/1.1 200 OK
  1808      Content-Type: application/x-tar
  1809  
  1810      Binary data stream
  1811  
  1812  Status Codes:
  1813  
  1814  -   **200** – no error
  1815  -   **500** – server error
  1816  
  1817  ### Load a tarball with a set of images and tags into docker
  1818  
  1819  `POST /images/load`
  1820  
  1821  Load a set of images and tags into a Docker repository.
  1822  See the [image tarball format](#image-tarball-format) for more details.
  1823  
  1824  **Example request**
  1825  
  1826      POST /images/load
  1827  
  1828      Tarball in body
  1829  
  1830  **Example response**:
  1831  
  1832      HTTP/1.1 200 OK
  1833  
  1834  Status Codes:
  1835  
  1836  -   **200** – no error
  1837  -   **500** – server error
  1838  
  1839  ### Image tarball format
  1840  
  1841  An image tarball contains one directory per image layer (named using its long ID),
  1842  each containing these files:
  1843  
  1844  - `VERSION`: currently `1.0` - the file format version
  1845  - `json`: detailed layer information, similar to `docker inspect layer_id`
  1846  - `layer.tar`: A tarfile containing the filesystem changes in this layer
  1847  
  1848  The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
  1849  for storing attribute changes and deletions.
  1850  
  1851  If the tarball defines a repository, the tarball should also include a `repositories` file at
  1852  the root that contains a list of repository and tag names mapped to layer IDs.
  1853  
  1854  ```
  1855  {"hello-world":
  1856      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1857  }
  1858  ```
  1859  
  1860  ### Exec Create
  1861  
  1862  `POST /containers/(id)/exec`
  1863  
  1864  Sets up an exec instance in a running container `id`
  1865  
  1866  **Example request**:
  1867  
  1868      POST /containers/e90e34656806/exec HTTP/1.1
  1869      Content-Type: application/json
  1870  
  1871        {
  1872         "AttachStdin": false,
  1873         "AttachStdout": true,
  1874         "AttachStderr": true,
  1875         "Tty": false,
  1876         "Cmd": [
  1877                       "date"
  1878               ]
  1879        }
  1880  
  1881  **Example response**:
  1882  
  1883      HTTP/1.1 201 OK
  1884      Content-Type: application/json
  1885  
  1886      {
  1887           "Id": "f90e34656806"
  1888           "Warnings":[]
  1889      }
  1890  
  1891  Json Parameters:
  1892  
  1893  -   **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
  1894  -   **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
  1895  -   **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
  1896  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  1897  -   **Cmd** - Command to run specified as a string or an array of strings.
  1898  
  1899  
  1900  Status Codes:
  1901  
  1902  -   **201** – no error
  1903  -   **404** – no such container
  1904  
  1905  ### Exec Start
  1906  
  1907  `POST /exec/(id)/start`
  1908  
  1909  Starts a previously set up `exec` instance `id`. If `detach` is true, this API
  1910  returns after starting the `exec` command. Otherwise, this API sets up an
  1911  interactive session with the `exec` command.
  1912  
  1913  **Example request**:
  1914  
  1915      POST /exec/e90e34656806/start HTTP/1.1
  1916      Content-Type: application/json
  1917  
  1918      {
  1919       "Detach": false,
  1920       "Tty": false
  1921      }
  1922  
  1923  **Example response**:
  1924  
  1925      HTTP/1.1 201 OK
  1926      Content-Type: application/json
  1927  
  1928      {{ STREAM }}
  1929  
  1930  Json Parameters:
  1931  
  1932  -   **Detach** - Detach from the `exec` command.
  1933  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  1934  
  1935  Status Codes:
  1936  
  1937  -   **201** – no error
  1938  -   **404** – no such exec instance
  1939  
  1940      **Stream details**:
  1941      Similar to the stream behavior of `POST /container/(id)/attach` API
  1942  
  1943  ### Exec Resize
  1944  
  1945  `POST /exec/(id)/resize`
  1946  
  1947  Resizes the `tty` session used by the `exec` command `id`.
  1948  This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
  1949  
  1950  **Example request**:
  1951  
  1952      POST /exec/e90e34656806/resize HTTP/1.1
  1953      Content-Type: text/plain
  1954  
  1955  **Example response**:
  1956  
  1957      HTTP/1.1 201 OK
  1958      Content-Type: text/plain
  1959  
  1960  Query Parameters:
  1961  
  1962  -   **h** – height of `tty` session
  1963  -   **w** – width
  1964  
  1965  Status Codes:
  1966  
  1967  -   **201** – no error
  1968  -   **404** – no such exec instance
  1969  
  1970  ### Exec Inspect
  1971  
  1972  `GET /exec/(id)/json`
  1973  
  1974  Return low-level information about the `exec` command `id`.
  1975  
  1976  **Example request**:
  1977  
  1978      GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  1979  
  1980  **Example response**:
  1981  
  1982      HTTP/1.1 200 OK
  1983      Content-Type: plain/text
  1984  
  1985      {
  1986        "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  1987        "Running" : false,
  1988        "ExitCode" : 2,
  1989        "ProcessConfig" : {
  1990          "privileged" : false,
  1991          "user" : "",
  1992          "tty" : false,
  1993          "entrypoint" : "sh",
  1994          "arguments" : [
  1995            "-c",
  1996            "exit 2"
  1997          ]
  1998        },
  1999        "OpenStdin" : false,
  2000        "OpenStderr" : false,
  2001        "OpenStdout" : false,
  2002        "Container" : {
  2003          "State" : {
  2004            "Running" : true,
  2005            "Paused" : false,
  2006            "Restarting" : false,
  2007            "OOMKilled" : false,
  2008            "Pid" : 3650,
  2009            "ExitCode" : 0,
  2010            "Error" : "",
  2011            "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  2012            "FinishedAt" : "0001-01-01T00:00:00Z"
  2013          },
  2014          "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  2015          "Created" : "2014-11-17T22:26:03.626304998Z",
  2016          "Path" : "date",
  2017          "Args" : [],
  2018          "Config" : {
  2019            "Hostname" : "8f177a186b97",
  2020            "Domainname" : "",
  2021            "User" : "",
  2022            "AttachStdin" : false,
  2023            "AttachStdout" : false,
  2024            "AttachStderr" : false,
  2025            "ExposedPorts" : null,
  2026            "Tty" : false,
  2027            "OpenStdin" : false,
  2028            "StdinOnce" : false,
  2029            "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2030            "Cmd" : [
  2031              "date"
  2032            ],
  2033            "Image" : "ubuntu",
  2034            "Volumes" : null,
  2035            "WorkingDir" : "",
  2036            "Entrypoint" : null,
  2037            "NetworkDisabled" : false,
  2038            "MacAddress" : "",
  2039            "OnBuild" : null,
  2040            "SecurityOpt" : null
  2041          },
  2042          "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2043          "NetworkSettings" : {
  2044            "IPAddress" : "172.17.0.2",
  2045            "IPPrefixLen" : 16,
  2046            "MacAddress" : "02:42:ac:11:00:02",
  2047            "Gateway" : "172.17.42.1",
  2048            "Bridge" : "docker0",
  2049            "PortMapping" : null,
  2050            "Ports" : {}
  2051          },
  2052          "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2053          "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2054          "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2055          "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2056          "Name" : "/test",
  2057          "Driver" : "aufs",
  2058          "ExecDriver" : "native-0.2",
  2059          "MountLabel" : "",
  2060          "ProcessLabel" : "",
  2061          "AppArmorProfile" : "",
  2062          "RestartCount" : 0,
  2063          "Volumes" : {},
  2064          "VolumesRW" : {}
  2065        }
  2066      }
  2067  
  2068  Status Codes:
  2069  
  2070  -   **200** – no error
  2071  -   **404** – no such exec instance
  2072  -   **500** - server error
  2073  
  2074  # 3. Going further
  2075  
  2076  ## 3.1 Inside `docker run`
  2077  
  2078  As an example, the `docker run` command line makes the following API calls:
  2079  
  2080  - Create the container
  2081  
  2082  - If the status code is 404, it means the image doesn't exist:
  2083      - Try to pull it.
  2084      - Then, retry to create the container.
  2085  
  2086  - Start the container.
  2087  
  2088  - If you are not in detached mode:
  2089  - Attach to the container, using `logs=1` (to have `stdout` and
  2090        `stderr` from the container's start) and `stream=1`
  2091  
  2092  - If in detached mode or only `stdin` is attached, display the container's id.
  2093  
  2094  ## 3.2 Hijacking
  2095  
  2096  In this version of the API, `/attach`, uses hijacking to transport `stdin`,
  2097  `stdout`, and `stderr` on the same socket.
  2098  
  2099  To hint potential proxies about connection hijacking, Docker client sends
  2100  connection upgrade headers similarly to websocket.
  2101  
  2102      Upgrade: tcp
  2103      Connection: Upgrade
  2104  
  2105  When Docker daemon detects the `Upgrade` header, it switches its status code
  2106  from **200 OK** to **101 UPGRADED** and resends the same headers.
  2107  
  2108  
  2109  ## 3.3 CORS Requests
  2110  
  2111  To set cross origin requests to the remote api please give values to 
  2112  `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
  2113  default or blank means CORS disabled
  2114  
  2115      $ docker -d -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"