github.com/netbrain/docker@v1.9.0-rc2/docs/reference/api/docker_remote_api_v1.10.md (about)

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