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

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