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

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