github.com/netbrain/docker@v1.9.0-rc2/docs/reference/api/docker_remote_api_v1.18.md (about)

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