github.com/pritambaral/docker@v1.4.2-0.20150120174542-b2fe1b3dd952/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  ### Wait a container
   449  
   450  `POST /containers/(id)/wait`
   451  
   452  Block until container `id` stops, then returns the exit code
   453  
   454  **Example request**:
   455  
   456          POST /containers/16253994b7c4/wait HTTP/1.1
   457  
   458  **Example response**:
   459  
   460          HTTP/1.1 200 OK
   461          Content-Type: application/json
   462  
   463          {"StatusCode": 0}
   464  
   465  Status Codes:
   466  
   467  -   **200** – no error
   468  -   **404** – no such container
   469  -   **500** – server error
   470  
   471  ### Remove a container
   472  
   473  `DELETE /containers/(id)`
   474  
   475  Remove the container `id` from the filesystem
   476  
   477  **Example request**:
   478  
   479          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   480  
   481  **Example response**:
   482  
   483          HTTP/1.1 204 No Content
   484  
   485  Query Parameters:
   486  
   487  -   **v** – 1/True/true or 0/False/false, Remove the volumes
   488          associated to the container. Default false
   489  
   490  Status Codes:
   491  
   492  -   **204** – no error
   493  -   **400** – bad parameter
   494  -   **404** – no such container
   495  -   **500** – server error
   496  
   497  ## 2.2 Images
   498  
   499  ### List Images
   500  
   501  `GET /images/(format)`
   502  
   503  List images `format` could be json or viz (json default)
   504  
   505  **Example request**:
   506  
   507          GET /images/json?all=0 HTTP/1.1
   508  
   509  **Example response**:
   510  
   511          HTTP/1.1 200 OK
   512          Content-Type: application/json
   513  
   514          [
   515               {
   516                       "Repository":"ubuntu",
   517                       "Tag":"precise",
   518                       "Id":"b750fe79269d",
   519                       "Created":1364102658,
   520                       "Size":24653,
   521                       "VirtualSize":180116135
   522               },
   523               {
   524                       "Repository":"ubuntu",
   525                       "Tag":"12.04",
   526                       "Id":"b750fe79269d",
   527                       "Created":1364102658,
   528                       "Size":24653,
   529                       "VirtualSize":180116135
   530               }
   531          ]
   532  
   533  **Example request**:
   534  
   535          GET /images/viz HTTP/1.1
   536  
   537  **Example response**:
   538  
   539          HTTP/1.1 200 OK
   540          Content-Type: text/plain
   541  
   542          digraph docker {
   543          "d82cbacda43a" -> "074be284591f"
   544          "1496068ca813" -> "08306dc45919"
   545          "08306dc45919" -> "0e7893146ac2"
   546          "b750fe79269d" -> "1496068ca813"
   547          base -> "27cf78414709" [style=invis]
   548          "f71189fff3de" -> "9a33b36209ed"
   549          "27cf78414709" -> "b750fe79269d"
   550          "0e7893146ac2" -> "d6434d954665"
   551          "d6434d954665" -> "d82cbacda43a"
   552          base -> "e9aa60c60128" [style=invis]
   553          "074be284591f" -> "f71189fff3de"
   554          "b750fe79269d" [label="b750fe79269d\nubuntu",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   555          "e9aa60c60128" [label="e9aa60c60128\ncentos",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   556          "9a33b36209ed" [label="9a33b36209ed\nfedora",shape=box,fillcolor="paleturquoise",style="filled,rounded"];
   557          base [style=invisible]
   558          }
   559  
   560  Query Parameters:
   561  
   562  -   **all** – 1/True/true or 0/False/false, Show all containers.
   563          Only running containers are shown by defaul
   564  
   565  Status Codes:
   566  
   567  -   **200** – no error
   568  -   **400** – bad parameter
   569  -   **500** – server error
   570  
   571  ### Create an image
   572  
   573  `POST /images/create`
   574  
   575  Create an image, either by pull it from the registry or by importing i
   576  
   577  **Example request**:
   578  
   579          POST /images/create?fromImage=ubuntu HTTP/1.1
   580  
   581  **Example response**:
   582  
   583          HTTP/1.1 200 OK
   584          Content-Type: application/json
   585  
   586          {"status":"Pulling..."}
   587          {"status":"Pulling", "progress":"1/? (n/a)"}
   588          {"error":"Invalid..."}
   589          ...
   590  
   591  Query Parameters:
   592  
   593  -   **fromImage** – name of the image to pull
   594  -   **fromSrc** – source to import, - means stdin
   595  -   **repo** – repository
   596  -   **tag** – tag
   597  -   **registry** – the registry to pull from
   598  
   599  Status Codes:
   600  
   601  -   **200** – no error
   602  -   **500** – server error
   603  
   604  ### Insert a file in an image
   605  
   606  `POST /images/(name)/insert`
   607  
   608  Insert a file from `url` in the image `name` at `path`
   609  
   610  **Example request**:
   611  
   612          POST /images/test/insert?path=/usr&url=myurl HTTP/1.1
   613  
   614  **Example response**:
   615  
   616          HTTP/1.1 200 OK
   617          Content-Type: application/json
   618  
   619          {"status":"Inserting..."}
   620          {"status":"Inserting", "progress":"1/? (n/a)"}
   621          {"error":"Invalid..."}
   622          ...
   623  
   624  Query Parameters:
   625  
   626  -	**url** – The url from where the file is taken
   627  -	**path** – The path where the file is stored
   628  
   629  Status Codes:
   630  
   631  -   **200** – no error
   632  -   **500** – server error
   633  
   634  ### Inspect an image
   635  
   636  `GET /images/(name)/json`
   637  
   638  Return low-level information on the image `name`
   639  
   640  **Example request**:
   641  
   642          GET /images/centos/json HTTP/1.1
   643  
   644  **Example response**:
   645  
   646          HTTP/1.1 200 OK
   647          Content-Type: application/json
   648  
   649          {
   650               "id":"b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   651               "parent":"27cf784147099545",
   652               "created":"2013-03-23T22:24:18.818426-07:00",
   653               "container":"3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
   654               "container_config":
   655                       {
   656                               "Hostname":"",
   657                               "User":"",
   658                               "Memory":0,
   659                               "MemorySwap":0,
   660                               "AttachStdin":false,
   661                               "AttachStdout":false,
   662                               "AttachStderr":false,
   663                               "PortSpecs":null,
   664                               "Tty":true,
   665                               "OpenStdin":true,
   666                               "StdinOnce":false,
   667                               "Env":null,
   668                               "Cmd": ["/bin/bash"],
   669                               "Dns":null,
   670                               "Image":"centos",
   671                               "Volumes":null,
   672                               "VolumesFrom":""
   673                       },
   674               "Size": 6824592
   675          }
   676  
   677  Status Codes:
   678  
   679  -   **200** – no error
   680  -   **404** – no such image
   681  -   **500** – server error
   682  
   683  ### Get the history of an image
   684  
   685  `GET /images/(name)/history`
   686  
   687  Return the history of the image `name`
   688  
   689  **Example request**:
   690  
   691          GET /images/fedora/history HTTP/1.1
   692  
   693  **Example response**:
   694  
   695          HTTP/1.1 200 OK
   696          Content-Type: application/json
   697  
   698          [
   699               {
   700                       "Id": "b750fe79269d",
   701                       "Created": 1364102658,
   702                       "CreatedBy": "/bin/bash"
   703               },
   704               {
   705                       "Id": "27cf78414709",
   706                       "Created": 1364068391,
   707                       "CreatedBy": ""
   708               }
   709          ]
   710  
   711  Status Codes:
   712  
   713  -   **200** – no error
   714  -   **404** – no such image
   715  -   **500** – server error
   716  
   717  ### Push an image on the registry
   718  
   719  `POST /images/(name)/push`
   720  
   721  Push the image `name` on the registry
   722  
   723      > **Example request**:
   724      >
   725      >     POST /images/test/push HTTP/1.1
   726      >     {{ authConfig }}
   727      >
   728      > **Example response**:
   729  
   730          HTTP/1.1 200 OK
   731          Content-Type: application/json
   732  
   733          {"status":"Pushing..."}
   734          {"status":"Pushing", "progress":"1/? (n/a)"}
   735          {"error":"Invalid..."}
   736          ...
   737  
   738  Status Codes:
   739  
   740  -   **200** – no error
   741  -   **404** – no such image
   742  -   **500** – server error
   743  
   744  ### Tag an image into a repository
   745  
   746  `POST /images/(name)/tag`
   747  
   748  Tag the image `name` into a repository
   749  
   750  **Example request**:
   751  
   752          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
   753  
   754  **Example response**:
   755  
   756          HTTP/1.1 201 OK
   757  
   758  Query Parameters:
   759  
   760  -   **repo** – The repository to tag in
   761  -   **force** – 1/True/true or 0/False/false, default false
   762  -   **tag** - The new tag name
   763  
   764  Status Codes:
   765  
   766  -   **201** – no error
   767  -   **400** – bad parameter
   768  -   **404** – no such image
   769  -   **409** – conflict
   770  -   **500** – server error
   771  
   772  ### Remove an image
   773  
   774  `DELETE /images/(name)`
   775  
   776  Remove the image `name` from the filesystem
   777  
   778  **Example request**:
   779  
   780          DELETE /images/test HTTP/1.1
   781  
   782  **Example response**:
   783  
   784          HTTP/1.1 200 OK
   785          Content-type: application/json
   786  
   787          [
   788           {"Untagged": "3e2f21a89f"},
   789           {"Deleted": "3e2f21a89f"},
   790           {"Deleted": "53b4f83ac9"}
   791          ]
   792  
   793  Status Codes:
   794  
   795  -   **200** – no error
   796  -   **404** – no such image
   797  -   **409** – conflict
   798  -   **500** – server error
   799  
   800  ### Search images
   801  
   802  `GET /images/search`
   803  
   804  Search for an image on [Docker Hub](https://hub.docker.com)
   805  
   806  **Example request**:
   807  
   808          GET /images/search?term=sshd HTTP/1.1
   809  
   810  **Example response**:
   811  
   812          HTTP/1.1 200 OK
   813          Content-Type: application/json
   814  
   815          [
   816               {
   817                       "Name":"cespare/sshd",
   818                       "Description":""
   819               },
   820               {
   821                       "Name":"johnfuller/sshd",
   822                       "Description":""
   823               },
   824               {
   825                       "Name":"dhrp/mongodb-sshd",
   826                       "Description":""
   827               }
   828          ]
   829  
   830          :query term: term to search
   831          :statuscode 200: no error
   832          :statuscode 500: server error
   833  
   834  ## 2.3 Misc
   835  
   836  ### Build an image from Dockerfile via stdin
   837  
   838  `POST /build`
   839  
   840  Build an image from Dockerfile via stdin
   841  
   842  **Example request**:
   843  
   844          POST /build HTTP/1.1
   845  
   846          {{ TAR STREAM }}
   847  
   848  **Example response**:
   849  
   850          HTTP/1.1 200 OK
   851  
   852          {{ STREAM }}
   853  
   854      The stream must be a tar archive compressed with one of the
   855      following algorithms: identity (no compression), gzip, bzip2, xz.
   856      The archive must include a file called Dockerfile at its root. I
   857      may include any number of other files, which will be accessible in
   858      the build context (See the ADD build command).
   859  
   860      The Content-type header should be set to "application/tar".
   861  
   862  Query Parameters:
   863  
   864  -   **t** – repository name (and optionally a tag) to be applied to
   865      the resulting image in case of success
   866  -   **q** – suppress verbose build output
   867  
   868  Status Codes:
   869  
   870  -   **200** – no error
   871  -   **500** – server error
   872  
   873  ### Check auth configuration
   874  
   875  `POST /auth`
   876  
   877  Get the default username and email
   878  
   879  **Example request**:
   880  
   881          POST /auth HTTP/1.1
   882          Content-Type: application/json
   883  
   884          {
   885               "username":"hannibal",
   886               "password:"xxxx",
   887               "email":"hannibal@a-team.com"
   888          }
   889  
   890  **Example response**:
   891  
   892          HTTP/1.1 200 OK
   893          Content-Type: text/plain
   894  
   895  Status Codes:
   896  
   897  -   **200** – no error
   898  -   **204** – no error
   899  -   **500** – server error
   900  
   901  ### Display system-wide information
   902  
   903  `GET /info`
   904  
   905  Display system-wide information
   906  
   907  **Example request**:
   908  
   909          GET /info HTTP/1.1
   910  
   911  **Example response**:
   912  
   913          HTTP/1.1 200 OK
   914          Content-Type: application/json
   915  
   916          {
   917               "Containers":11,
   918               "Images":16,
   919               "Debug":false,
   920               "NFd": 11,
   921               "NGoroutines":21,
   922               "MemoryLimit":true,
   923               "SwapLimit":false,
   924               "EventsListeners":"0",
   925               "LXCVersion":"0.7.5",
   926               "KernelVersion":"3.8.0-19-generic"
   927          }
   928  
   929  Status Codes:
   930  
   931  -   **200** – no error
   932  -   **500** – server error
   933  
   934  ### Show the docker version information
   935  
   936  `GET /version`
   937  
   938  Show the docker version information
   939  
   940  **Example request**:
   941  
   942          GET /version HTTP/1.1
   943  
   944  **Example response**:
   945  
   946          HTTP/1.1 200 OK
   947          Content-Type: application/json
   948  
   949          {
   950               "Version":"0.2.2",
   951               "GitCommit":"5a2a5cc+CHANGES",
   952               "GoVersion":"go1.0.3"
   953          }
   954  
   955  Status Codes:
   956  
   957  -   **200** – no error
   958  -   **500** – server error
   959  
   960  ### Create a new image from a container's changes
   961  
   962  `POST /commit`
   963  
   964  Create a new image from a container's changes
   965  
   966  **Example request**:
   967  
   968          POST /commit?container=44c004db4b17&m=message&repo=myrepo HTTP/1.1
   969          Content-Type: application/json
   970  
   971          {
   972              "Cmd": ["cat", "/world"],
   973              "PortSpecs":["22"]
   974          }
   975  
   976  **Example response**:
   977  
   978          HTTP/1.1 201 OK
   979              Content-Type: application/vnd.docker.raw-stream
   980  
   981          {"Id": "596069db4bf5"}
   982  
   983  Query Parameters:
   984  
   985  -   **container** – source container
   986  -   **repo** – repository
   987  -   **tag** – tag
   988  -   **m** – commit message
   989  -   **author** – author (e.g., "John Hannibal Smith
   990          <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
   991  
   992  Status Codes:
   993  
   994  -   **201** – no error
   995  -   **404** – no such container
   996  -   **500** – server error
   997  
   998  ### Monitor Docker's events
   999  
  1000  `GET /events`
  1001  
  1002  Get events from docker, either in real time via streaming, or via
  1003  polling (using since).
  1004  
  1005  Docker containers will report the following events:
  1006  
  1007      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1008  
  1009  and Docker images will report:
  1010  
  1011      untag, delete
  1012  
  1013  **Example request**:
  1014  
  1015          GET /events?since=1374067924
  1016  
  1017  **Example response**:
  1018  
  1019          HTTP/1.1 200 OK
  1020          Content-Type: application/json
  1021  
  1022          {"status":"create","id":"dfdf82bd3881","time":1374067924}
  1023          {"status":"start","id":"dfdf82bd3881","time":1374067924}
  1024          {"status":"stop","id":"dfdf82bd3881","time":1374067966}
  1025          {"status":"destroy","id":"dfdf82bd3881","time":1374067970}
  1026  
  1027  Query Parameters:
  1028  
  1029  -   **since** – timestamp used for polling
  1030  
  1031  Status Codes:
  1032  
  1033  -   **200** – no error
  1034  -   **500** – server error
  1035  
  1036  # 3. Going further
  1037  
  1038  ## 3.1 Inside `docker run`
  1039  
  1040  Here are the steps of `docker run` :
  1041  
  1042   - Create the container
  1043  
  1044   - If the status code is 404, it means the image doesn't exist:
  1045          - Try to pull it
  1046          - Then retry to create the container
  1047  
  1048   - Start the container
  1049  
  1050   - If you are not in detached mode:
  1051          - Attach to the container, using logs=1 (to have stdout and
  1052              stderr from the container's start) and stream=1
  1053  
  1054   - If in detached mode or only stdin is attached:
  1055          - Display the container's id
  1056  
  1057  ## 3.2 Hijacking
  1058  
  1059  In this version of the API, /attach, uses hijacking to transport stdin,
  1060  stdout and stderr on the same socket. This might change in the future.
  1061  
  1062  ## 3.3 CORS Requests
  1063  
  1064  To enable cross origin requests to the remote api add the flag
  1065  "--api-enable-cors" when running docker in daemon mode.
  1066  
  1067  > docker -d -H="192.168.1.9:2375" -api-enable-cors