github.com/robertojrojas/docker@v1.9.1/docs/reference/api/docker_remote_api_v1.4.md (about)

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