github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/docs/sources/reference/api/docker_remote_api_v1.7.md (about)

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