github.com/eikeon/docker@v1.5.0-rc4/docs/sources/reference/api/docker_remote_api_v1.6.md (about)

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