github.com/pritambaral/docker@v1.4.2-0.20150120174542-b2fe1b3dd952/docs/sources/reference/api/docker_remote_api_v1.10.md (about)

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