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

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