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

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