github.com/feiyang21687/docker@v1.5.0/docs/sources/reference/api/docker_remote_api_v1.4.md (about)

     1  page_title: Remote API v1.4
     2  page_description: API Documentation for Docker
     3  page_keywords: API, Docker, rcli, REST, documentation
     4  
     5  # Docker Remote API v1.4
     6  
     7  # 1. Brief introduction
     8  
     9  - The Remote API is replacing rcli
    10  - Default port in the docker daemon is 2375
    11  - The API tends to be REST, but for some complex commands, like attach
    12    or pull, the HTTP connection is hijacked to transport stdout stdin
    13    and stderr
    14  
    15  # 2. Endpoints
    16  
    17  ## 2.1 Containers
    18  
    19  ### List containers
    20  
    21  `GET /containers/json`
    22  
    23  List containers
    24  
    25  **Example request**:
    26  
    27          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    28  
    29  **Example response**:
    30  
    31          HTTP/1.1 200 OK
    32          Content-Type: application/json
    33  
    34          [
    35               {
    36                       "Id": "8dfafdbc3a40",
    37                       "Image": "ubuntu:latest",
    38                       "Command": "echo 1",
    39                       "Created": 1367854155,
    40                       "Status": "Exit 0",
    41                       "Ports":"",
    42                       "SizeRw":12288,
    43                       "SizeRootFs":0
    44               },
    45               {
    46                       "Id": "9cd87474be90",
    47                       "Image": "ubuntu:latest",
    48                       "Command": "echo 222222",
    49                       "Created": 1367854155,
    50                       "Status": "Exit 0",
    51                       "Ports":"",
    52                       "SizeRw":12288,
    53                       "SizeRootFs":0
    54               },
    55               {
    56                       "Id": "3176a2479c92",
    57                       "Image": "centos:latest",
    58                       "Command": "echo 3333333333333333",
    59                       "Created": 1367854154,
    60                       "Status": "Exit 0",
    61                       "Ports":"",
    62                       "SizeRw":12288,
    63                       "SizeRootFs":0
    64               },
    65               {
    66                       "Id": "4cb07b47f9fb",
    67                       "Image": "fedora:latest",
    68                       "Command": "echo 444444444444444444444444444444444",
    69                       "Created": 1367854152,
    70                       "Status": "Exit 0",
    71                       "Ports":"",
    72                       "SizeRw":12288,
    73                       "SizeRootFs":0
    74               }
    75          ]
    76  
    77  Query Parameters:
    78  
    79       
    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 containers, include non-running ones.
    84  -   **since** – Show only containers created since Id, include non-running ones.
    85  -   **before** – Show only containers created before Id, include non-running ones.
    86  -   **size** – 1/True/true or 0/False/false, Show the containers sizes
    87  
    88  Status Codes:
    89  
    90  -   **200** – no error
    91  -   **400** – bad parameter
    92  -   **500** – server error
    93  
    94  ### Create a container
    95  
    96  `POST /containers/create`
    97  
    98  Create a container
    99  
   100  **Example request**:
   101  
   102          POST /containers/create HTTP/1.1
   103          Content-Type: application/json
   104  
   105          {
   106               "Hostname":"",
   107               "User":"",
   108               "Memory":0,
   109               "MemorySwap":0,
   110               "AttachStdin":false,
   111               "AttachStdout":true,
   112               "AttachStderr":true,
   113               "PortSpecs":null,
   114               "Privileged": false,
   115               "Tty":false,
   116               "OpenStdin":false,
   117               "StdinOnce":false,
   118               "Env":null,
   119               "Cmd":[
   120                       "date"
   121               ],
   122               "Dns":null,
   123               "Image":"ubuntu",
   124               "Volumes":{},
   125               "VolumesFrom":"",
   126               "WorkingDir":""
   127  
   128          }
   129  
   130  **Example response**:
   131  
   132          HTTP/1.1 201 Created
   133          Content-Type: application/json
   134  
   135          {
   136               "Id":"e90e34656806"
   137               "Warnings":[]
   138          }
   139  
   140  Json Parameters:
   141  
   142  -   **config** – the container's configuration
   143  
   144  Status Codes:
   145  
   146  -   **201** – no error
   147  -   **404** – no such container
   148  -   **406** – impossible to attach (container not running)
   149  -   **500** – server error
   150  
   151  ### Inspect a container
   152  
   153  `GET /containers/(id)/json`
   154  
   155  Return low-level information on the container `id`
   156  
   157  
   158  **Example request**:
   159  
   160          GET /containers/4fa6e0f0c678/json HTTP/1.1
   161  
   162  **Example response**:
   163  
   164          HTTP/1.1 200 OK
   165          Content-Type: application/json
   166  
   167          {
   168                       "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
   169                       "Created": "2013-05-07T14:51:42.041847+02:00",
   170                       "Path": "date",
   171                       "Args": [],
   172                       "Config": {
   173                               "Hostname": "4fa6e0f0c678",
   174                               "User": "",
   175                               "Memory": 0,
   176                               "MemorySwap": 0,
   177                               "AttachStdin": false,
   178                               "AttachStdout": true,
   179                               "AttachStderr": true,
   180                               "PortSpecs": null,
   181                               "Tty": false,
   182                               "OpenStdin": false,
   183                               "StdinOnce": false,
   184                               "Env": null,
   185                               "Cmd": [
   186                                       "date"
   187                               ],
   188                               "Dns": null,
   189                               "Image": "ubuntu",
   190                               "Volumes": {},
   191                               "VolumesFrom": "",
   192                               "WorkingDir": ""
   193                       },
   194                       "State": {
   195                               "Running": false,
   196                               "Pid": 0,
   197                               "ExitCode": 0,
   198                               "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
   199                               "Ghost": false
   200                       },
   201                       "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   202                       "NetworkSettings": {
   203                               "IpAddress": "",
   204                               "IpPrefixLen": 0,
   205                               "Gateway": "",
   206                               "Bridge": "",
   207                               "PortMapping": null
   208                       },
   209                       "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker",
   210                       "ResolvConfPath": "/etc/resolv.conf",
   211                       "Volumes": {}
   212          }
   213  
   214  Status Codes:
   215  
   216  -   **200** – no error
   217  -   **404** – no such container
   218  -   **409** – conflict between containers and images
   219  -   **500** – server error
   220  
   221  ### List processes running inside a container
   222  
   223  `GET /containers/(id)/top`
   224  
   225  List processes running inside the container `id`
   226  
   227  **Example request**:
   228  
   229          GET /containers/4fa6e0f0c678/top HTTP/1.1
   230  
   231  **Example response**:
   232  
   233          HTTP/1.1 200 OK
   234          Content-Type: application/json
   235  
   236          {
   237               "Titles": [
   238                       "USER",
   239                       "PID",
   240                       "%CPU",
   241                       "%MEM",
   242                       "VSZ",
   243                       "RSS",
   244                       "TTY",
   245                       "STAT",
   246                       "START",
   247                       "TIME",
   248                       "COMMAND"
   249                       ],
   250               "Processes": [
   251                       ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   252                       ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   253               ]
   254          }
   255  
   256  Query Parameters:
   257  
   258  -   **ps_args** – ps arguments to use (e.g., aux)
   259  
   260  Status Codes:
   261  
   262  -   **200** – no error
   263  -   **404** – no such container
   264  -   **500** – server error
   265  
   266  ### Inspect changes on a container's filesystem
   267  
   268  `GET /containers/(id)/changes`
   269  
   270  Inspect changes on container `id`'s filesystem
   271  
   272  **Example request**:
   273  
   274          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   275  
   276  **Example response**:
   277  
   278          HTTP/1.1 200 OK
   279          Content-Type: application/json
   280  
   281          [
   282               {
   283                       "Path": "/dev",
   284                       "Kind": 0
   285               },
   286               {
   287                       "Path": "/dev/kmsg",
   288                       "Kind": 1
   289               },
   290               {
   291                       "Path": "/test",
   292                       "Kind": 1
   293               }
   294          ]
   295  
   296  Status Codes:
   297  
   298  -   **200** – no error
   299  -   **404** – no such container
   300  -   **500** – server error
   301  
   302  ### Export a container
   303  
   304  `GET /containers/(id)/export`
   305  
   306  Export the contents of container `id`
   307  
   308  **Example request**:
   309  
   310          GET /containers/4fa6e0f0c678/export HTTP/1.1
   311  
   312  **Example response**:
   313  
   314          HTTP/1.1 200 OK
   315          Content-Type: application/octet-stream
   316  
   317          {{ TAR STREAM }}
   318  
   319  Status Codes:
   320  
   321  -   **200** – no error
   322  -   **404** – no such container
   323  -   **500** – server error
   324  
   325  ### Start a container
   326  
   327  `POST /containers/(id)/start`
   328  
   329  Start the container `id`
   330  
   331  **Example request**:
   332  
   333          POST /containers/(id)/start HTTP/1.1
   334          Content-Type: application/json
   335  
   336          {
   337               "Binds":["/tmp:/tmp"],
   338               "LxcConf":[{"Key":"lxc.utsname","Value":"docker"}]
   339          }
   340  
   341  **Example response**:
   342  
   343          HTTP/1.1 204 No Content
   344          Content-Type: text/plain
   345  
   346  Json Parameters:
   347  
   348       
   349  
   350  -   **hostConfig** – the container's host configuration (optional)
   351  
   352  Status Codes:
   353  
   354  -   **204** – no error
   355  -   **404** – no such container
   356  -   **500** – server error
   357  
   358  ### Stop a container
   359  
   360  `POST /containers/(id)/stop`
   361  
   362  Stop the container `id`
   363  
   364  **Example request**:
   365  
   366          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   367  
   368  **Example response**:
   369  
   370          HTTP/1.1 204 OK
   371  
   372  Query Parameters:
   373  
   374  -   **t** – number of seconds to wait before killing the container
   375  
   376  Status Codes:
   377  
   378  -   **204** – no error
   379  -   **404** – no such container
   380  -   **500** – server error
   381  
   382  ### Restart a container
   383  
   384  `POST /containers/(id)/restart`
   385  
   386  Restart the container `id`
   387  
   388  **Example request**:
   389  
   390          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   391  
   392  **Example response**:
   393  
   394          HTTP/1.1 204 No Content
   395  
   396  Query Parameters:
   397  
   398  -   **t** – number of seconds to wait before killing the container
   399  
   400  Status Codes:
   401  
   402  -   **204** – no error
   403  -   **404** – no such container
   404  -   **500** – server error
   405  
   406  ### Kill a container
   407  
   408  `POST /containers/(id)/kill`
   409  
   410  Kill the container `id`
   411  
   412  **Example request**:
   413  
   414          POST /containers/e90e34656806/kill HTTP/1.1
   415  
   416  **Example response**:
   417  
   418          HTTP/1.1 204 No Content
   419  
   420  Status Codes:
   421  
   422  -   **204** – no error
   423  -   **404** – no such container
   424  -   **500** – server error
   425  
   426  ### Attach to a container
   427  
   428  `POST /containers/(id)/attach`
   429  
   430  Attach to the container `id`
   431  
   432  **Example request**:
   433  
   434          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   435  
   436  **Example response**:
   437  
   438          HTTP/1.1 200 OK
   439          Content-Type: application/vnd.docker.raw-stream
   440  
   441          {{ STREAM }}
   442  
   443  Query Parameters:
   444  
   445  -   **logs** – 1/True/true or 0/False/false, return logs. Defaul
   446          false
   447  -   **stream** – 1/True/true or 0/False/false, return stream.
   448          Default false
   449  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   450          to stdin. Default false
   451  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   452          stdout log, if stream=true, attach to stdout. Default false
   453  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   454          stderr log, if stream=true, attach to stderr. Default false
   455  
   456  Status Codes:
   457  
   458  -   **200** – no error
   459  -   **400** – bad parameter
   460  -   **404** – no such container
   461  -   **500** – server error
   462  
   463  ### Attach to a container (websocket)
   464  
   465  `GET /containers/(id)/attach/ws`
   466  
   467  Attach to the container `id` via websocket
   468  
   469  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   470  
   471  **Example request**
   472  
   473          GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   474  
   475  **Example response**
   476  
   477          {{ STREAM }}
   478  
   479  Query Parameters:
   480  
   481  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   482  -   **stream** – 1/True/true or 0/False/false, return stream.
   483          Default false
   484  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   485          to stdin. Default false
   486  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   487          stdout log, if stream=true, attach to stdout. Default false
   488  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   489          stderr log, if stream=true, attach to stderr. Default false
   490  
   491  Status Codes:
   492  
   493  -   **200** – no error
   494  -   **400** – bad parameter
   495  -   **404** – no such container
   496  -   **500** – server error
   497  
   498  ### Wait a container
   499  
   500  `POST /containers/(id)/wait`
   501  
   502  Block until container `id` stops, then returns the exit code
   503  
   504  **Example request**:
   505  
   506          POST /containers/16253994b7c4/wait HTTP/1.1
   507  
   508  **Example response**:
   509  
   510          HTTP/1.1 200 OK
   511          Content-Type: application/json
   512  
   513          {"StatusCode": 0}
   514  
   515  Status Codes:
   516  
   517  -   **200** – no error
   518  -   **404** – no such container
   519  -   **500** – server error
   520  
   521  ### Remove a container
   522  
   523  `DELETE /containers/(id)`
   524  
   525  Remove the container `id` from the filesystem
   526  
   527  **Example request**:
   528  
   529          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   530  
   531  **Example response**:
   532  
   533          HTTP/1.1 204 No Content
   534  
   535  Query Parameters:
   536  
   537  -   **v** – 1/True/true or 0/False/false, Remove the volumes
   538          associated to the container. Default false
   539  
   540  Status Codes:
   541  
   542  -   **204** – no error
   543  -   **400** – bad parameter
   544  -   **404** – no such container
   545  -   **500** – server error
   546  
   547  ### Copy files or folders from a container
   548  
   549  `POST /containers/(id)/copy`
   550  
   551  Copy files or folders of container `id`
   552  
   553  **Example request**:
   554  
   555          POST /containers/4fa6e0f0c678/copy HTTP/1.1
   556          Content-Type: application/json
   557  
   558          {
   559               "Resource": "test.txt"
   560          }
   561  
   562  **Example response**:
   563  
   564          HTTP/1.1 200 OK
   565          Content-Type: application/octet-stream
   566  
   567          {{ TAR STREAM }}
   568  
   569  Status Codes:
   570  
   571  -   **200** – no error
   572  -   **404** – no such container
   573  -   **500** – server error
   574  
   575  ## 2.2 Images
   576  
   577  ### List Images
   578  
   579  `GET /images/(format)`
   580  
   581  List images `format` could be json or viz (json default)
   582  
   583  **Example request**:
   584  
   585          GET /images/json?all=0 HTTP/1.1
   586  
   587  **Example response**:
   588  
   589          HTTP/1.1 200 OK
   590          Content-Type: application/json
   591  
   592          [
   593               {
   594                       "Repository":"ubuntu",
   595                       "Tag":"precise",
   596                       "Id":"b750fe79269d",
   597                       "Created":1364102658,
   598                       "Size":24653,
   599                       "VirtualSize":180116135
   600               },
   601               {
   602                       "Repository":"ubuntu",
   603                       "Tag":"12.04",
   604                       "Id":"b750fe79269d",
   605                       "Created":1364102658,
   606                       "Size":24653,
   607                       "VirtualSize":180116135
   608               }
   609          ]
   610  
   611  **Example request**:
   612  
   613          GET /images/viz HTTP/1.1
   614  
   615  **Example response**:
   616  
   617          HTTP/1.1 200 OK
   618          Content-Type: text/plain
   619  
   620          digraph docker {
   621          "d82cbacda43a" -> "074be284591f"
   622          "1496068ca813" -> "08306dc45919"
   623          "08306dc45919" -> "0e7893146ac2"
   624          "b750fe79269d" -> "1496068ca813"
   625          base -> "27cf78414709" [style=invis]
   626          "f71189fff3de" -> "9a33b36209ed"
   627          "27cf78414709" -> "b750fe79269d"
   628          "0e7893146ac2" -> "d6434d954665"
   629          "d6434d954665" -> "d82cbacda43a"
   630          base -> "e9aa60c60128" [style=invis]
   631          "074be284591f" -> "f71189fff3de"
   632          "b750fe79269d" [label="b750fe79269d\nubuntu",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   633          "e9aa60c60128" [label="e9aa60c60128\ncentos",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   634          "9a33b36209ed" [label="9a33b36209ed\nfedora",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   635          base [style=invisible]
   636          }
   637  
   638  Query Parameters:
   639  
   640  -   **all** – 1/True/true or 0/False/false, Show all containers.
   641          Only running containers are shown by defaul
   642  
   643  Status Codes:
   644  
   645  -   **200** – no error
   646  -   **400** – bad parameter
   647  -   **500** – server error
   648  
   649  ### Create an image
   650  
   651  `POST /images/create`
   652  
   653  Create an image, either by pull it from the registry or by importing i
   654  
   655  **Example request**:
   656  
   657          POST /images/create?fromImage=ubuntu HTTP/1.1
   658  
   659  **Example response**:
   660  
   661          HTTP/1.1 200 OK
   662          Content-Type: application/json
   663  
   664          {"status":"Pulling..."}
   665          {"status":"Pulling", "progress":"1/? (n/a)"}
   666          {"error":"Invalid..."}
   667          ...
   668  
   669  Query Parameters:
   670  
   671  -   **fromImage** – name of the image to pull
   672  -   **fromSrc** – source to import, - means stdin
   673  -   **repo** – repository
   674  -   **tag** – tag
   675  -   **registry** – the registry to pull from
   676  
   677  Status Codes:
   678  
   679  -   **200** – no error
   680  -   **500** – server error
   681  
   682  ### Insert a file in an image
   683  
   684  `POST /images/(name)/insert`
   685  
   686  Insert a file from `url` in the image `name` at `path`
   687  
   688  **Example request**:
   689  
   690          POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
   691  
   692  **Example response**:
   693  
   694          HTTP/1.1 200 OK
   695          Content-Type: application/json
   696  
   697          {"status":"Inserting..."}
   698          {"status":"Inserting", "progress":"1/? (n/a)"}
   699          {"error":"Invalid..."}
   700          ...
   701  
   702  Query Parameters:
   703  
   704  -	**url** – The url from where the file is taken
   705  -	**path** – The path where the file is stored
   706  
   707  Status Codes:
   708  
   709  -   **200** – no error
   710  -   **500** – server error
   711  
   712  ### Inspect an image
   713  
   714  `GET /images/(name)/json`
   715  
   716  Return low-level information on the image `name`
   717  
   718  **Example request**:
   719  
   720          GET /images/centos/json HTTP/1.1
   721  
   722  **Example response**:
   723  
   724          HTTP/1.1 200 OK
   725          Content-Type: application/json
   726  
   727          {
   728               "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   729               "parent":"27cf784147099545",
   730               "created":"2013-03-23T22:24:18.818426-07:00",
   731               "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
   732               "container_config":
   733                       {
   734                               "Hostname":"",
   735                               "User":"",
   736                               "Memory":0,
   737                               "MemorySwap":0,
   738                               "AttachStdin":false,
   739                               "AttachStdout":false,
   740                               "AttachStderr":false,
   741                               "PortSpecs":null,
   742                               "Tty":true,
   743                               "OpenStdin":true,
   744                               "StdinOnce":false,
   745                               "Env":null,
   746                               "Cmd": ["/bin/bash"],
   747                               "Dns":null,
   748                               "Image":"centos",
   749                               "Volumes":null,
   750                               "VolumesFrom":"",
   751                               "WorkingDir":""
   752                       },
   753               "Size": 6824592
   754          }
   755  
   756  Status Codes:
   757  
   758  -   **200** – no error
   759  -   **404** – no such image
   760  -   **409** – conflict between containers and images
   761  -   **500** – server error
   762  
   763  ### Get the history of an image
   764  
   765  `GET /images/(name)/history`
   766  
   767  Return the history of the image `name`
   768  
   769  **Example request**:
   770  
   771          GET /images/fedora/history HTTP/1.1
   772  
   773  **Example response**:
   774  
   775          HTTP/1.1 200 OK
   776          Content-Type: application/json
   777  
   778          [
   779               {
   780                       "Id": "b750fe79269d",
   781                       "Created": 1364102658,
   782                       "CreatedBy": "/bin/bash"
   783               },
   784               {
   785                       "Id": "27cf78414709",
   786                       "Created": 1364068391,
   787                       "CreatedBy": ""
   788               }
   789          ]
   790  
   791  Status Codes:
   792  
   793  -   **200** – no error
   794  -   **404** – no such image
   795  -   **500** – server error
   796  
   797  ### Push an image on the registry
   798  
   799  `POST /images/(name)/push`
   800  
   801  Push the image `name` on the registry
   802  
   803  **Example request**:
   804  
   805          POST /images/test/push HTTP/1.1
   806          {{ authConfig }}
   807  
   808  **Example response**:
   809  
   810          HTTP/1.1 200 OK
   811          Content-Type: application/json
   812  
   813      {"status":"Pushing..."} {"status":"Pushing", "progress":"1/? (n/a)"}
   814      {"error":"Invalid..."} ...
   815  
   816  Status Codes:
   817  
   818  -   **200** – no error :statuscode 404: no such image :statuscode
   819          500: server error
   820  
   821  ### Tag an image into a repository
   822  
   823  `POST /images/(name)/tag`
   824  
   825  Tag the image `name` into a repository
   826  
   827  **Example request**:
   828  
   829          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
   830  
   831  **Example response**:
   832  
   833          HTTP/1.1 201 OK
   834  
   835  Query Parameters:
   836  
   837  -   **repo** – The repository to tag in
   838  -   **force** – 1/True/true or 0/False/false, default false
   839  -   **tag** - The new tag name
   840  
   841  Status Codes:
   842  
   843  -   **201** – no error
   844  -   **400** – bad parameter
   845  -   **404** – no such image
   846  -   **409** – conflict
   847  -   **500** – server error
   848  
   849  ### Remove an image
   850  
   851  `DELETE /images/(name)`
   852  
   853  Remove the image `name` from the filesystem
   854  
   855  **Example request**:
   856  
   857          DELETE /images/test HTTP/1.1
   858  
   859  **Example response**:
   860  
   861          HTTP/1.1 200 OK
   862          Content-type: application/json
   863  
   864          [
   865           {"Untagged": "3e2f21a89f"},
   866           {"Deleted": "3e2f21a89f"},
   867           {"Deleted": "53b4f83ac9"}
   868          ]
   869  
   870  Status Codes:
   871  
   872  -   **200** – no error
   873  -   **404** – no such image
   874  -   **409** – conflict
   875  -   **500** – server error
   876  
   877  ### Search images
   878  
   879  `GET /images/search`
   880  
   881  Search for an image on [Docker Hub](https://hub.docker.com)
   882  
   883  **Example request**:
   884  
   885          GET /images/search?term=sshd HTTP/1.1
   886  
   887  **Example response**:
   888  
   889          HTTP/1.1 200 OK
   890          Content-Type: application/json
   891  
   892          [
   893               {
   894                       "Name":"cespare/sshd",
   895                       "Description":""
   896               },
   897               {
   898                       "Name":"johnfuller/sshd",
   899                       "Description":""
   900               },
   901               {
   902                       "Name":"dhrp/mongodb-sshd",
   903                       "Description":""
   904               }
   905          ]
   906  
   907          :query term: term to search
   908          :statuscode 200: no error
   909          :statuscode 500: server error
   910  
   911  ## 2.3 Misc
   912  
   913  ### Build an image from Dockerfile via stdin
   914  
   915  `POST /build`
   916  
   917  Build an image from Dockerfile via stdin
   918  
   919  **Example request**:
   920  
   921          POST /build HTTP/1.1
   922  
   923          {{ TAR STREAM }}
   924  
   925  **Example response**:
   926  
   927          HTTP/1.1 200 OK
   928  
   929          {{ STREAM }}
   930  
   931      The stream must be a tar archive compressed with one of the
   932      following algorithms: identity (no compression), gzip, bzip2, xz.
   933      The archive must include a file called Dockerfile at its root. I
   934      may include any number of other files, which will be accessible in
   935      the build context (See the ADD build command).
   936  
   937      The Content-type header should be set to "application/tar".
   938  
   939  Query Parameters:
   940  
   941  -   **t** – repository name (and optionally a tag) to be applied to
   942      the resulting image in case of success
   943  -   **remote** – build source URI (git or HTTPS/HTTP)
   944  -   **q** – suppress verbose build output
   945  -   **nocache** – do not use the cache when building the image
   946  
   947  Status Codes:
   948  
   949  -   **200** – no error
   950  -   **500** – server error
   951  
   952  ### Check auth configuration
   953  
   954  `POST /auth`
   955  
   956  Get the default username and email
   957  
   958  **Example request**:
   959  
   960          POST /auth HTTP/1.1
   961          Content-Type: application/json
   962  
   963          {
   964               "username":" hannibal",
   965               "password: "xxxx",
   966               "email": "hannibal@a-team.com",
   967               "serveraddress": "https://index.docker.io/v1/"
   968          }
   969  
   970  **Example response**:
   971  
   972          HTTP/1.1 200 OK
   973          Content-Type: text/plain
   974  
   975  Status Codes:
   976  
   977  -   **200** – no error
   978  -   **204** – no error
   979  -   **500** – server error
   980  
   981  ### Display system-wide information
   982  
   983  `GET /info`
   984  
   985  Display system-wide information
   986  
   987  **Example request**:
   988  
   989          GET /info HTTP/1.1
   990  
   991  **Example response**:
   992  
   993          HTTP/1.1 200 OK
   994          Content-Type: application/json
   995  
   996          {
   997               "Containers":11,
   998               "Images":16,
   999               "Debug":false,
  1000               "NFd": 11,
  1001               "NGoroutines":21,
  1002               "MemoryLimit":true,
  1003               "SwapLimit":false,
  1004               "IPv4Forwarding":true
  1005          }
  1006  
  1007  Status Codes:
  1008  
  1009  -   **200** – no error
  1010  -   **500** – server error
  1011  
  1012  ### Show the docker version information
  1013  
  1014  `GET /version`
  1015  
  1016  Show the docker version information
  1017  
  1018  
  1019  **Example request**:
  1020  
  1021          GET /version HTTP/1.1
  1022  
  1023  **Example response**:
  1024  
  1025          HTTP/1.1 200 OK
  1026          Content-Type: application/json
  1027  
  1028          {
  1029               "Version":"0.2.2",
  1030               "GitCommit":"5a2a5cc+CHANGES",
  1031               "GoVersion":"go1.0.3"
  1032          }
  1033  
  1034  Status Codes:
  1035  
  1036  -   **200** – no error
  1037  -   **500** – server error
  1038  
  1039  ### Create a new image from a container's changes
  1040  
  1041  `POST /commit`
  1042  
  1043  Create a new image from a container's changes
  1044  
  1045  **Example request**:
  1046  
  1047          POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
  1048          Content-Type: application/json
  1049  
  1050          {
  1051              "Cmd": ["cat", "/world"],
  1052              "PortSpecs":["22"]
  1053          }
  1054  
  1055  **Example response**:
  1056  
  1057          HTTP/1.1 201 OK
  1058              Content-Type: application/vnd.docker.raw-stream
  1059  
  1060          {"Id": "596069db4bf5"}
  1061  
  1062  Query Parameters:
  1063  
  1064  -   **container** – source container
  1065  -   **repo** – repository
  1066  -   **tag** – tag
  1067  -   **m** – commit message
  1068  -   **author** – author (e.g., "John Hannibal Smith
  1069          <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1070  
  1071  Status Codes:
  1072  
  1073  -   **201** – no error
  1074  -   **404** – no such container
  1075  -   **500** – server error
  1076  
  1077  ### Monitor Docker's events
  1078  
  1079  `GET /events`
  1080  
  1081  Get events from docker, either in real time via streaming, or via
  1082  polling (using since).
  1083  
  1084  Docker containers will report the following events:
  1085  
  1086      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1087  
  1088  and Docker images will report:
  1089  
  1090      untag, delete
  1091  
  1092  **Example request**:
  1093  
  1094          GET /events?since=1374067924
  1095  
  1096  **Example response**:
  1097  
  1098          HTTP/1.1 200 OK
  1099          Content-Type: application/json
  1100  
  1101          {"status":"create","id":"dfdf82bd3881","from":"ubuntu:latest","time":1374067924}
  1102          {"status":"start","id":"dfdf82bd3881","from":"ubuntu:latest","time":1374067924}
  1103          {"status":"stop","id":"dfdf82bd3881","from":"ubuntu:latest","time":1374067966}
  1104          {"status":"destroy","id":"dfdf82bd3881","from":"ubuntu:latest","time":1374067970}
  1105  
  1106  Query Parameters:
  1107  
  1108  -   **since** – timestamp used for polling
  1109  
  1110  Status Codes:
  1111  
  1112  -   **200** – no error
  1113  -   **500** – server error
  1114  
  1115  # 3. Going further
  1116  
  1117  ## 3.1 Inside `docker run`
  1118  
  1119  Here are the steps of `docker run` :
  1120  
  1121   - Create the container
  1122  
  1123   - If the status code is 404, it means the image doesn't exist:
  1124          - Try to pull it
  1125          - Then retry to create the container
  1126  
  1127   - Start the container
  1128  
  1129   - If you are not in detached mode:
  1130          - Attach to the container, using logs=1 (to have stdout and
  1131              stderr from the container's start) and stream=1
  1132  
  1133   - If in detached mode or only stdin is attached:
  1134          - Display the container's id
  1135  
  1136  ## 3.2 Hijacking
  1137  
  1138  In this version of the API, /attach, uses hijacking to transport stdin,
  1139  stdout and stderr on the same socket. This might change in the future.
  1140  
  1141  ## 3.3 CORS Requests
  1142  
  1143  To enable cross origin requests to the remote api add the flag
  1144  "--api-enable-cors" when running docker in daemon mode.
  1145  
  1146      $ docker -d -H="192.168.1.9:2375" --api-enable-cors