github.com/eikeon/docker@v1.5.0-rc4/docs/sources/reference/api/docker_remote_api_v1.17.md (about)

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