github.com/slene/docker@v1.8.0-rc1/docs/reference/api/docker_remote_api_v1.6.md (about)

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