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

     1  page_title: Remote API v1.4
     2  page_description: API Documentation for Docker
     3  page_keywords: API, Docker, rcli, REST, documentation
     4  
     5  # Docker Remote API v1.4
     6  
     7  # 1. Brief introduction
     8  
     9  - The Remote API is replacing rcli
    10  - Default port in the docker daemon is 2375
    11  - The API tends to be REST, but for some complex commands, like attach
    12    or pull, the HTTP connection is hijacked to transport stdout stdin
    13    and stderr
    14  
    15  # 2. Endpoints
    16  
    17  ## 2.1 Containers
    18  
    19  ### List containers
    20  
    21  `GET /containers/json`
    22  
    23  List containers
    24  
    25  **Example request**:
    26  
    27          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    28  
    29  **Example response**:
    30  
    31          HTTP/1.1 200 OK
    32          Content-Type: application/json
    33  
    34          [
    35               {
    36                       "Id": "8dfafdbc3a40",
    37                       "Image": "ubuntu:latest",
    38                       "Command": "echo 1",
    39                       "Created": 1367854155,
    40                       "Status": "Exit 0",
    41                       "Ports":"",
    42                       "SizeRw":12288,
    43                       "SizeRootFs":0
    44               },
    45               {
    46                       "Id": "9cd87474be90",
    47                       "Image": "ubuntu:latest",
    48                       "Command": "echo 222222",
    49                       "Created": 1367854155,
    50                       "Status": "Exit 0",
    51                       "Ports":"",
    52                       "SizeRw":12288,
    53                       "SizeRootFs":0
    54               },
    55               {
    56                       "Id": "3176a2479c92",
    57                       "Image": "centos:latest",
    58                       "Command": "echo 3333333333333333",
    59                       "Created": 1367854154,
    60                       "Status": "Exit 0",
    61                       "Ports":"",
    62                       "SizeRw":12288,
    63                       "SizeRootFs":0
    64               },
    65               {
    66                       "Id": "4cb07b47f9fb",
    67                       "Image": "fedora:latest",
    68                       "Command": "echo 444444444444444444444444444444444",
    69                       "Created": 1367854152,
    70                       "Status": "Exit 0",
    71                       "Ports":"",
    72                       "SizeRw":12288,
    73                       "SizeRootFs":0
    74               }
    75          ]
    76  
    77  Query Parameters:
    78  
    79       
    80  
    81  -   **all** – 1/True/true or 0/False/false, Show all containers.
    82      Only running containers are shown by default (i.e., this defaults to false)
    83  -   **limit** – Show `limit` last created containers, include non-running ones.
    84  -   **since** – Show only containers created since Id, include non-running ones.
    85  -   **before** – Show only containers created before Id, include non-running ones.
    86  -   **size** – 1/True/true or 0/False/false, Show the containers sizes
    87  
    88  Status Codes:
    89  
    90  -   **200** – no error
    91  -   **400** – bad parameter
    92  -   **500** – server error
    93  
    94  ### Create a container
    95  
    96  `POST /containers/create`
    97  
    98  Create a container
    99  
   100  **Example request**:
   101  
   102          POST /containers/create HTTP/1.1
   103          Content-Type: application/json
   104  
   105          {
   106               "Hostname":"",
   107               "User":"",
   108               "Memory":0,
   109               "MemorySwap":0,
   110               "AttachStdin":false,
   111               "AttachStdout":true,
   112               "AttachStderr":true,
   113               "PortSpecs":null,
   114               "Privileged": false,
   115               "Tty":false,
   116               "OpenStdin":false,
   117               "StdinOnce":false,
   118               "Env":null,
   119               "Cmd":[
   120                       "date"
   121               ],
   122               "Dns":null,
   123               "Image":"ubuntu",
   124               "Volumes":{},
   125               "VolumesFrom":"",
   126               "WorkingDir":""
   127  
   128          }
   129  
   130  **Example response**:
   131  
   132          HTTP/1.1 201 Created
   133          Content-Type: application/json
   134  
   135          {
   136               "Id":"e90e34656806"
   137               "Warnings":[]
   138          }
   139  
   140  Json Parameters:
   141  
   142  -   **config** – the container's configuration
   143  
   144  Status Codes:
   145  
   146  -   **201** – no error
   147  -   **404** – no such container
   148  -   **406** – impossible to attach (container not running)
   149  -   **500** – server error
   150  
   151  ### Inspect a container
   152  
   153  `GET /containers/(id)/json`
   154  
   155  Return low-level information on the container `id`
   156  
   157  
   158  **Example request**:
   159  
   160          GET /containers/4fa6e0f0c678/json HTTP/1.1
   161  
   162  **Example response**:
   163  
   164          HTTP/1.1 200 OK
   165          Content-Type: application/json
   166  
   167          {
   168                       "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
   169                       "Created": "2013-05-07T14:51:42.041847+02:00",
   170                       "Path": "date",
   171                       "Args": [],
   172                       "Config": {
   173                               "Hostname": "4fa6e0f0c678",
   174                               "User": "",
   175                               "Memory": 0,
   176                               "MemorySwap": 0,
   177                               "AttachStdin": false,
   178                               "AttachStdout": true,
   179                               "AttachStderr": true,
   180                               "PortSpecs": null,
   181                               "Tty": false,
   182                               "OpenStdin": false,
   183                               "StdinOnce": false,
   184                               "Env": null,
   185                               "Cmd": [
   186                                       "date"
   187                               ],
   188                               "Dns": null,
   189                               "Image": "ubuntu",
   190                               "Volumes": {},
   191                               "VolumesFrom": "",
   192                               "WorkingDir": ""
   193                       },
   194                       "State": {
   195                               "Running": false,
   196                               "Pid": 0,
   197                               "ExitCode": 0,
   198                               "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
   199                               "Ghost": false
   200                       },
   201                       "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   202                       "NetworkSettings": {
   203                               "IpAddress": "",
   204                               "IpPrefixLen": 0,
   205                               "Gateway": "",
   206                               "Bridge": "",
   207                               "PortMapping": null
   208                       },
   209                       "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker",
   210                       "ResolvConfPath": "/etc/resolv.conf",
   211                       "Volumes": {}
   212          }
   213  
   214  Status Codes:
   215  
   216  -   **200** – no error
   217  -   **404** – no such container
   218  -   **409** – conflict between containers and images
   219  -   **500** – server error
   220  
   221  ### List processes running inside a container
   222  
   223  `GET /containers/(id)/top`
   224  
   225  List processes running inside the container `id`
   226  
   227  **Example request**:
   228  
   229          GET /containers/4fa6e0f0c678/top HTTP/1.1
   230  
   231  **Example response**:
   232  
   233          HTTP/1.1 200 OK
   234          Content-Type: application/json
   235  
   236          {
   237               "Titles": [
   238                       "USER",
   239                       "PID",
   240                       "%CPU",
   241                       "%MEM",
   242                       "VSZ",
   243                       "RSS",
   244                       "TTY",
   245                       "STAT",
   246                       "START",
   247                       "TIME",
   248                       "COMMAND"
   249                       ],
   250               "Processes": [
   251                       ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   252                       ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   253               ]
   254          }
   255  
   256  Query Parameters:
   257  
   258  -   **ps_args** – ps arguments to use (e.g., aux)
   259  
   260  Status Codes:
   261  
   262  -   **200** – no error
   263  -   **404** – no such container
   264  -   **500** – server error
   265  
   266  ### Inspect changes on a container's filesystem
   267  
   268  `GET /containers/(id)/changes`
   269  
   270  Inspect changes on container `id`'s filesystem
   271  
   272  **Example request**:
   273  
   274          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   275  
   276  **Example response**:
   277  
   278          HTTP/1.1 200 OK
   279          Content-Type: application/json
   280  
   281          [
   282               {
   283                       "Path": "/dev",
   284                       "Kind": 0
   285               },
   286               {
   287                       "Path": "/dev/kmsg",
   288                       "Kind": 1
   289               },
   290               {
   291                       "Path": "/test",
   292                       "Kind": 1
   293               }
   294          ]
   295  
   296  Status Codes:
   297  
   298  -   **200** – no error
   299  -   **404** – no such container
   300  -   **500** – server error
   301  
   302  ### Export a container
   303  
   304  `GET /containers/(id)/export`
   305  
   306  Export the contents of container `id`
   307  
   308  **Example request**:
   309  
   310          GET /containers/4fa6e0f0c678/export HTTP/1.1
   311  
   312  **Example response**:
   313  
   314          HTTP/1.1 200 OK
   315          Content-Type: application/octet-stream
   316  
   317          {{ TAR STREAM }}
   318  
   319  Status Codes:
   320  
   321  -   **200** – no error
   322  -   **404** – no such container
   323  -   **500** – server error
   324  
   325  ### Start a container
   326  
   327  `POST /containers/(id)/start`
   328  
   329  Start the container `id`
   330  
   331  **Example request**:
   332  
   333          POST /containers/(id)/start HTTP/1.1
   334          Content-Type: application/json
   335  
   336          {
   337               "Binds":["/tmp:/tmp"],
   338               "LxcConf":[{"Key":"lxc.utsname","Value":"docker"}]
   339          }
   340  
   341  **Example response**:
   342  
   343          HTTP/1.1 204 No Content
   344          Content-Type: text/plain
   345  
   346  Json Parameters:
   347  
   348       
   349  
   350  -   **hostConfig** – the container's host configuration (optional)
   351  
   352  Status Codes:
   353  
   354  -   **204** – no error
   355  -   **404** – no such container
   356  -   **500** – server error
   357  
   358  ### Stop a container
   359  
   360  `POST /containers/(id)/stop`
   361  
   362  Stop the container `id`
   363  
   364  **Example request**:
   365  
   366          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   367  
   368  **Example response**:
   369  
   370          HTTP/1.1 204 OK
   371  
   372  Query Parameters:
   373  
   374  -   **t** – number of seconds to wait before killing the container
   375  
   376  Status Codes:
   377  
   378  -   **204** – no error
   379  -   **404** – no such container
   380  -   **500** – server error
   381  
   382  ### Restart a container
   383  
   384  `POST /containers/(id)/restart`
   385  
   386  Restart the container `id`
   387  
   388  **Example request**:
   389  
   390          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   391  
   392  **Example response**:
   393  
   394          HTTP/1.1 204 No Content
   395  
   396  Query Parameters:
   397  
   398  -   **t** – number of seconds to wait before killing the container
   399  
   400  Status Codes:
   401  
   402  -   **204** – no error
   403  -   **404** – no such container
   404  -   **500** – server error
   405  
   406  ### Kill a container
   407  
   408  `POST /containers/(id)/kill`
   409  
   410  Kill the container `id`
   411  
   412  **Example request**:
   413  
   414          POST /containers/e90e34656806/kill HTTP/1.1
   415  
   416  **Example response**:
   417  
   418          HTTP/1.1 204 No Content
   419  
   420  Status Codes:
   421  
   422  -   **204** – no error
   423  -   **404** – no such container
   424  -   **500** – server error
   425  
   426  ### Attach to a container
   427  
   428  `POST /containers/(id)/attach`
   429  
   430  Attach to the container `id`
   431  
   432  **Example request**:
   433  
   434          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   435  
   436  **Example response**:
   437  
   438          HTTP/1.1 200 OK
   439          Content-Type: application/vnd.docker.raw-stream
   440  
   441          {{ STREAM }}
   442  
   443  Query Parameters:
   444  
   445  -   **logs** – 1/True/true or 0/False/false, return logs. Defaul
   446          false
   447  -   **stream** – 1/True/true or 0/False/false, return stream.
   448          Default false
   449  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   450          to stdin. Default false
   451  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   452          stdout log, if stream=true, attach to stdout. Default false
   453  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   454          stderr log, if stream=true, attach to stderr. Default false
   455  
   456  Status Codes:
   457  
   458  -   **200** – no error
   459  -   **400** – bad parameter
   460  -   **404** – no such container
   461  -   **500** – server error
   462  
   463  ### Wait a container
   464  
   465  `POST /containers/(id)/wait`
   466  
   467  Block until container `id` stops, then returns the exit code
   468  
   469  **Example request**:
   470  
   471          POST /containers/16253994b7c4/wait HTTP/1.1
   472  
   473  **Example response**:
   474  
   475          HTTP/1.1 200 OK
   476          Content-Type: application/json
   477  
   478          {"StatusCode": 0}
   479  
   480  Status Codes:
   481  
   482  -   **200** – no error
   483  -   **404** – no such container
   484  -   **500** – server error
   485  
   486  ### Remove a container
   487  
   488  `DELETE /containers/(id)`
   489  
   490  Remove the container `id` from the filesystem
   491  
   492  **Example request**:
   493  
   494          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   495  
   496  **Example response**:
   497  
   498          HTTP/1.1 204 No Content
   499  
   500  Query Parameters:
   501  
   502  -   **v** – 1/True/true or 0/False/false, Remove the volumes
   503          associated to the container. Default false
   504  
   505  Status Codes:
   506  
   507  -   **204** – no error
   508  -   **400** – bad parameter
   509  -   **404** – no such container
   510  -   **500** – server error
   511  
   512  ### Copy files or folders from a container
   513  
   514  `POST /containers/(id)/copy`
   515  
   516  Copy files or folders of container `id`
   517  
   518  **Example request**:
   519  
   520          POST /containers/4fa6e0f0c678/copy HTTP/1.1
   521          Content-Type: application/json
   522  
   523          {
   524               "Resource": "test.txt"
   525          }
   526  
   527  **Example response**:
   528  
   529          HTTP/1.1 200 OK
   530          Content-Type: application/octet-stream
   531  
   532          {{ TAR STREAM }}
   533  
   534  Status Codes:
   535  
   536  -   **200** – no error
   537  -   **404** – no such container
   538  -   **500** – server error
   539  
   540  ## 2.2 Images
   541  
   542  ### List Images
   543  
   544  `GET /images/(format)`
   545  
   546  List images `format` could be json or viz (json default)
   547  
   548  **Example request**:
   549  
   550          GET /images/json?all=0 HTTP/1.1
   551  
   552  **Example response**:
   553  
   554          HTTP/1.1 200 OK
   555          Content-Type: application/json
   556  
   557          [
   558               {
   559                       "Repository":"ubuntu",
   560                       "Tag":"precise",
   561                       "Id":"b750fe79269d",
   562                       "Created":1364102658,
   563                       "Size":24653,
   564                       "VirtualSize":180116135
   565               },
   566               {
   567                       "Repository":"ubuntu",
   568                       "Tag":"12.04",
   569                       "Id":"b750fe79269d",
   570                       "Created":1364102658,
   571                       "Size":24653,
   572                       "VirtualSize":180116135
   573               }
   574          ]
   575  
   576  **Example request**:
   577  
   578          GET /images/viz HTTP/1.1
   579  
   580  **Example response**:
   581  
   582          HTTP/1.1 200 OK
   583          Content-Type: text/plain
   584  
   585          digraph docker {
   586          "d82cbacda43a" -> "074be284591f"
   587          "1496068ca813" -> "08306dc45919"
   588          "08306dc45919" -> "0e7893146ac2"
   589          "b750fe79269d" -> "1496068ca813"
   590          base -> "27cf78414709" [style=invis]
   591          "f71189fff3de" -> "9a33b36209ed"
   592          "27cf78414709" -> "b750fe79269d"
   593          "0e7893146ac2" -> "d6434d954665"
   594          "d6434d954665" -> "d82cbacda43a"
   595          base -> "e9aa60c60128" [style=invis]
   596          "074be284591f" -> "f71189fff3de"
   597          "b750fe79269d" [label="b750fe79269d\nubuntu",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   598          "e9aa60c60128" [label="e9aa60c60128\ncentos",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   599          "9a33b36209ed" [label="9a33b36209ed\nfedora",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   600          base [style=invisible]
   601          }
   602  
   603  Query Parameters:
   604  
   605  -   **all** – 1/True/true or 0/False/false, Show all containers.
   606          Only running containers are shown by defaul
   607  
   608  Status Codes:
   609  
   610  -   **200** – no error
   611  -   **400** – bad parameter
   612  -   **500** – server error
   613  
   614  ### Create an image
   615  
   616  `POST /images/create`
   617  
   618  Create an image, either by pull it from the registry or by importing i
   619  
   620  **Example request**:
   621  
   622          POST /images/create?fromImage=ubuntu HTTP/1.1
   623  
   624  **Example response**:
   625  
   626          HTTP/1.1 200 OK
   627          Content-Type: application/json
   628  
   629          {"status":"Pulling..."}
   630          {"status":"Pulling", "progress":"1/? (n/a)"}
   631          {"error":"Invalid..."}
   632          ...
   633  
   634  Query Parameters:
   635  
   636  -   **fromImage** – name of the image to pull
   637  -   **fromSrc** – source to import, - means stdin
   638  -   **repo** – repository
   639  -   **tag** – tag
   640  -   **registry** – the registry to pull from
   641  
   642  Status Codes:
   643  
   644  -   **200** – no error
   645  -   **500** – server error
   646  
   647  ### Insert a file in an image
   648  
   649  `POST /images/(name)/insert`
   650  
   651  Insert a file from `url` in the image `name` at `path`
   652  
   653  **Example request**:
   654  
   655          POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
   656  
   657  **Example response**:
   658  
   659          HTTP/1.1 200 OK
   660          Content-Type: application/json
   661  
   662          {"status":"Inserting..."}
   663          {"status":"Inserting", "progress":"1/? (n/a)"}
   664          {"error":"Invalid..."}
   665          ...
   666  
   667  Query Parameters:
   668  
   669  -	**url** – The url from where the file is taken
   670  -	**path** – The path where the file is stored
   671  
   672  Status Codes:
   673  
   674  -   **200** – no error
   675  -   **500** – server error
   676  
   677  ### Inspect an image
   678  
   679  `GET /images/(name)/json`
   680  
   681  Return low-level information on the image `name`
   682  
   683  **Example request**:
   684  
   685          GET /images/centos/json HTTP/1.1
   686  
   687  **Example response**:
   688  
   689          HTTP/1.1 200 OK
   690          Content-Type: application/json
   691  
   692          {
   693               "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   694               "parent":"27cf784147099545",
   695               "created":"2013-03-23T22:24:18.818426-07:00",
   696               "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
   697               "container_config":
   698                       {
   699                               "Hostname":"",
   700                               "User":"",
   701                               "Memory":0,
   702                               "MemorySwap":0,
   703                               "AttachStdin":false,
   704                               "AttachStdout":false,
   705                               "AttachStderr":false,
   706                               "PortSpecs":null,
   707                               "Tty":true,
   708                               "OpenStdin":true,
   709                               "StdinOnce":false,
   710                               "Env":null,
   711                               "Cmd": ["/bin/bash"],
   712                               "Dns":null,
   713                               "Image":"centos",
   714                               "Volumes":null,
   715                               "VolumesFrom":"",
   716                               "WorkingDir":""
   717                       },
   718               "Size": 6824592
   719          }
   720  
   721  Status Codes:
   722  
   723  -   **200** – no error
   724  -   **404** – no such image
   725  -   **409** – conflict between containers and images
   726  -   **500** – server error
   727  
   728  ### Get the history of an image
   729  
   730  `GET /images/(name)/history`
   731  
   732  Return the history of the image `name`
   733  
   734  **Example request**:
   735  
   736          GET /images/fedora/history HTTP/1.1
   737  
   738  **Example response**:
   739  
   740          HTTP/1.1 200 OK
   741          Content-Type: application/json
   742  
   743          [
   744               {
   745                       "Id": "b750fe79269d",
   746                       "Created": 1364102658,
   747                       "CreatedBy": "/bin/bash"
   748               },
   749               {
   750                       "Id": "27cf78414709",
   751                       "Created": 1364068391,
   752                       "CreatedBy": ""
   753               }
   754          ]
   755  
   756  Status Codes:
   757  
   758  -   **200** – no error
   759  -   **404** – no such image
   760  -   **500** – server error
   761  
   762  ### Push an image on the registry
   763  
   764  `POST /images/(name)/push`
   765  
   766  Push the image `name` on the registry
   767  
   768  **Example request**:
   769  
   770          POST /images/test/push HTTP/1.1
   771          {{ authConfig }}
   772  
   773  **Example response**:
   774  
   775          HTTP/1.1 200 OK
   776          Content-Type: application/json
   777  
   778      {"status":"Pushing..."} {"status":"Pushing", "progress":"1/? (n/a)"}
   779      {"error":"Invalid..."} ...
   780  
   781  Status Codes:
   782  
   783  -   **200** – no error :statuscode 404: no such image :statuscode
   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  -   **q** – suppress verbose build output
   909  -   **nocache** – do not use the cache when building the image
   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               "serveraddress": "https://index.docker.io/v1/"
   932          }
   933  
   934  **Example response**:
   935  
   936          HTTP/1.1 200 OK
   937          Content-Type: text/plain
   938  
   939  Status Codes:
   940  
   941  -   **200** – no error
   942  -   **204** – no error
   943  -   **500** – server error
   944  
   945  ### Display system-wide information
   946  
   947  `GET /info`
   948  
   949  Display system-wide information
   950  
   951  **Example request**:
   952  
   953          GET /info HTTP/1.1
   954  
   955  **Example response**:
   956  
   957          HTTP/1.1 200 OK
   958          Content-Type: application/json
   959  
   960          {
   961               "Containers":11,
   962               "Images":16,
   963               "Debug":false,
   964               "NFd": 11,
   965               "NGoroutines":21,
   966               "MemoryLimit":true,
   967               "SwapLimit":false,
   968               "IPv4Forwarding":true
   969          }
   970  
   971  Status Codes:
   972  
   973  -   **200** – no error
   974  -   **500** – server error
   975  
   976  ### Show the docker version information
   977  
   978  `GET /version`
   979  
   980  Show the docker version information
   981  
   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","from":"ubuntu:latest","time":1374067924}
  1066          {"status":"start","id":"dfdf82bd3881","from":"ubuntu:latest","time":1374067924}
  1067          {"status":"stop","id":"dfdf82bd3881","from":"ubuntu:latest","time":1374067966}
  1068          {"status":"destroy","id":"dfdf82bd3881","from":"ubuntu:latest","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