github.com/pritambaral/docker@v1.4.2-0.20150120174542-b2fe1b3dd952/docs/sources/reference/api/docker_remote_api_v1.5.md (about)

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