github.com/nf/docker@v1.8.1/docs/reference/api/docker_remote_api_v1.3.md (about)

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