github.com/SophiaGitHub/hello@v1.7.1-rc3/docs/reference/api/docker_remote_api_v1.15.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.15"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent = "smn_remoteapi"
     8  weight = 6
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.15
    13  
    14  ## 1. Brief introduction
    15  
    16   - The Remote API has replaced `rcli`.
    17   - The daemon listens on `unix:///var/run/docker.sock` but you can
    18     [Bind Docker to another host/port or a Unix socket](
    19     /articles/basics/#bind-docker-to-another-hostport-or-a-unix-socket).
    20   - The API tends to be REST, but for some complex commands, like `attach`
    21     or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
    22     `STDIN` and `STDERR`.
    23  
    24  # 2. Endpoints
    25  
    26  ## 2.1 Containers
    27  
    28  ### List containers
    29  
    30  `GET /containers/json`
    31  
    32  List containers
    33  
    34  **Example request**:
    35  
    36          GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    37  
    38  **Example response**:
    39  
    40          HTTP/1.1 200 OK
    41          Content-Type: application/json
    42  
    43          [
    44               {
    45                       "Id": "8dfafdbc3a40",
    46                       "Image": "ubuntu:latest",
    47                       "Command": "echo 1",
    48                       "Created": 1367854155,
    49                       "Status": "Exit 0",
    50                       "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    51                       "SizeRw": 12288,
    52                       "SizeRootFs": 0
    53               },
    54               {
    55                       "Id": "9cd87474be90",
    56                       "Image": "ubuntu:latest",
    57                       "Command": "echo 222222",
    58                       "Created": 1367854155,
    59                       "Status": "Exit 0",
    60                       "Ports": [],
    61                       "SizeRw": 12288,
    62                       "SizeRootFs": 0
    63               },
    64               {
    65                       "Id": "3176a2479c92",
    66                       "Image": "ubuntu:latest",
    67                       "Command": "echo 3333333333333333",
    68                       "Created": 1367854154,
    69                       "Status": "Exit 0",
    70                       "Ports":[],
    71                       "SizeRw":12288,
    72                       "SizeRootFs":0
    73               },
    74               {
    75                       "Id": "4cb07b47f9fb",
    76                       "Image": "ubuntu:latest",
    77                       "Command": "echo 444444444444444444444444444444444",
    78                       "Created": 1367854152,
    79                       "Status": "Exit 0",
    80                       "Ports": [],
    81                       "SizeRw": 12288,
    82                       "SizeRootFs": 0
    83               }
    84          ]
    85  
    86  Query Parameters:
    87  
    88  -   **all** – 1/True/true or 0/False/false, Show all containers.
    89          Only running containers are shown by default (i.e., this defaults to false)
    90  -   **limit** – Show `limit` last created
    91          containers, include non-running ones.
    92  -   **since** – Show only containers created since Id, include
    93          non-running ones.
    94  -   **before** – Show only containers created before Id, include
    95          non-running ones.
    96  -   **size** – 1/True/true or 0/False/false, Show the containers
    97          sizes
    98  -   **filters** - a json encoded value of the filters (a map[string][]string) to process on the containers list. Available filters:
    99    -   exited=&lt;int&gt; -- containers with exit code of &lt;int&gt;
   100    -   status=(restarting|running|paused|exited)
   101  
   102  Status Codes:
   103  
   104  -   **200** – no error
   105  -   **400** – bad parameter
   106  -   **500** – server error
   107  
   108  ### Create a container
   109  
   110  `POST /containers/create`
   111  
   112  Create a container
   113  
   114  **Example request**:
   115  
   116          POST /containers/create HTTP/1.1
   117          Content-Type: application/json
   118  
   119          {
   120               "Hostname": "",
   121               "Domainname": "",
   122               "User": "",
   123               "Memory": 0,
   124               "MemorySwap": 0,
   125               "CpuShares": 512,
   126               "Cpuset": "0,1",
   127               "AttachStdin": false,
   128               "AttachStdout": true,
   129               "AttachStderr": true,
   130               "Tty": false,
   131               "OpenStdin": false,
   132               "StdinOnce": false,
   133               "Env": null,
   134               "Cmd": [
   135                       "date"
   136               ],
   137               "Entrypoint": "",
   138               "Image": "ubuntu",
   139               "Volumes": {
   140                       "/tmp": {}
   141               },
   142               "WorkingDir": "",
   143               "NetworkDisabled": false,
   144               "MacAddress": "12:34:56:78:9a:bc",
   145               "ExposedPorts": {
   146                       "22/tcp": {}
   147               },
   148               "SecurityOpts": [""],
   149               "HostConfig": {
   150                 "Binds": ["/tmp:/tmp"],
   151                 "Links": ["redis3:redis"],
   152                 "LxcConf": {"lxc.utsname":"docker"},
   153                 "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   154                 "PublishAllPorts": false,
   155                 "Privileged": false,
   156                 "Dns": ["8.8.8.8"],
   157                 "DnsSearch": [""],
   158                 "ExtraHosts": null,
   159                 "VolumesFrom": ["parent", "other:ro"],
   160                 "CapAdd": ["NET_ADMIN"],
   161                 "CapDrop": ["MKNOD"],
   162                 "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   163                 "NetworkMode": "bridge",
   164                 "Devices": []
   165              }
   166          }
   167  
   168  **Example response**:
   169  
   170          HTTP/1.1 201 Created
   171          Content-Type: application/json
   172  
   173          {
   174               "Id": "f91ddc4b01e079c4481a8340bbbeca4dbd33d6e4a10662e499f8eacbb5bf252b"
   175               "Warnings": []
   176          }
   177  
   178  Json Parameters:
   179  
   180  -   **Hostname** - A string value containing the desired hostname to use for the
   181        container.
   182  -   **Domainname** - A string value containing the desired domain name to use
   183        for the container.
   184  -   **User** - A string value containing the user to use inside the container.
   185  -   **Memory** - Memory limit in bytes.
   186  -   **MemorySwap**- Total memory usage (memory + swap); set `-1` to disable swap.
   187  -   **CpuShares** - An integer value containing the CPU Shares for container
   188        (ie. the relative weight vs other containers).
   189      **CpuSet** - String value containing the cgroups Cpuset to use.
   190  -   **AttachStdin** - Boolean value, attaches to stdin.
   191  -   **AttachStdout** - Boolean value, attaches to stdout.
   192  -   **AttachStderr** - Boolean value, attaches to stderr.
   193  -   **Tty** - Boolean value, Attach standard streams to a tty, including stdin if it is not closed.
   194  -   **OpenStdin** - Boolean value, opens stdin,
   195  -   **StdinOnce** - Boolean value, close stdin after the 1 attached client disconnects.
   196  -   **Env** - A list of environment variables in the form of `VAR=value`
   197  -   **Cmd** - Command to run specified as a string or an array of strings.
   198  -   **Entrypoint** - Set the entrypoint for the container a a string or an array
   199        of strings
   200  -   **Image** - String value containing the image name to use for the container
   201  -   **Volumes** – An object mapping mountpoint paths (strings) inside the
   202          container to empty objects.
   203  -   **WorkingDir** - A string value containing the working dir for commands to
   204        run in.
   205  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   206        container
   207  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   208        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   209  -   **SecurityOpts**: A list of string values to customize labels for MLS
   210        systems, such as SELinux.
   211  -   **HostConfig**
   212    -   **Binds** – A list of volume bindings for this container.  Each volume
   213            binding is a string of the form `container_path` (to create a new
   214            volume for the container), `host_path:container_path` (to bind-mount
   215            a host path into the container), or `host_path:container_path:ro`
   216            (to make the bind-mount read-only inside the container).
   217    -   **Links** - A list of links for the container.  Each link entry should be
   218          in the form of "container_name:alias".
   219    -   **LxcConf** - LXC specific configurations.  These configurations will only
   220          work when using the `lxc` execution driver.
   221    -   **PortBindings** - A map of exposed container ports and the host port they
   222          should map to. It should be specified in the form
   223          `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   224          Take note that `port` is specified as a string and not an integer value.
   225    -   **PublishAllPorts** - Allocates a random host port for all of a container's
   226          exposed ports. Specified as a boolean value.
   227    -   **Privileged** - Gives the container full access to the host.  Specified as
   228          a boolean value.
   229    -   **Dns** - A list of dns servers for the container to use.
   230    -   **DnsSearch** - A list of DNS search domains
   231    -   **ExtraHosts** - A list of hostnames/IP mappings to be added to the
   232        container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   233    -   **VolumesFrom** - A list of volumes to inherit from another container.
   234          Specified in the form `<container name>[:<ro|rw>]`
   235    -   **CapAdd** - A list of kernel capabilities to add to the container.
   236    -   **Capdrop** - A list of kernel capabilities to drop from the container.
   237    -   **RestartPolicy** – The behavior to apply when the container exits.  The
   238            value is an object with a `Name` property of either `"always"` to
   239            always restart or `"on-failure"` to restart only when the container
   240            exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   241            controls the number of times to retry before giving up.
   242            The default is not to restart. (optional)
   243            An ever increasing delay (double the previous delay, starting at 100mS)
   244            is added before each restart to prevent flooding the server.
   245    -   **NetworkMode** - Sets the networking mode for the container. Supported
   246          values are: `bridge`, `host`, and `container:<name|id>`
   247    -   **Devices** - A list of devices to add to the container specified in the
   248          form
   249          `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   250  
   251  Query Parameters:
   252  
   253  -   **name** – Assign the specified name to the container. Must
   254      match `/?[a-zA-Z0-9_-]+`.
   255  
   256  Status Codes:
   257  
   258  -   **201** – no error
   259  -   **404** – no such container
   260  -   **406** – impossible to attach (container not running)
   261  -   **500** – server error
   262  
   263  ### Inspect a container
   264  
   265  `GET /containers/(id)/json`
   266  
   267  Return low-level information on the container `id`
   268  
   269  
   270  **Example request**:
   271  
   272          GET /containers/4fa6e0f0c678/json HTTP/1.1
   273  
   274  **Example response**:
   275  
   276          HTTP/1.1 200 OK
   277          Content-Type: application/json
   278  
   279          {
   280                       "Id": "4fa6e0f0c6786287e131c3852c58a2e01cc697a68231826813597e4994f1d6e2",
   281                       "Created": "2013-05-07T14:51:42.041847+02:00",
   282                       "Path": "date",
   283                       "Args": [],
   284                       "Config": {
   285                               "Hostname": "4fa6e0f0c678",
   286                               "User": "",
   287                               "Memory": 0,
   288                               "MemorySwap": 0,
   289                               "AttachStdin": false,
   290                               "AttachStdout": true,
   291                               "AttachStderr": true,
   292                               "PortSpecs": null,
   293                               "Tty": false,
   294                               "OpenStdin": false,
   295                               "StdinOnce": false,
   296                               "Env": null,
   297                               "Cmd": [
   298                                       "date"
   299                               ],
   300                               "Dns": null,
   301                               "Image": "ubuntu",
   302                               "Volumes": {},
   303                               "VolumesFrom": "",
   304                               "WorkingDir": ""
   305                       },
   306                       "State": {
   307                               "Running": false,
   308                               "Pid": 0,
   309                               "ExitCode": 0,
   310                               "StartedAt": "2013-05-07T14:51:42.087658+02:01360",
   311                               "Ghost": false
   312                       },
   313                       "Image": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   314                       "NetworkSettings": {
   315                               "IpAddress": "",
   316                               "IpPrefixLen": 0,
   317                               "Gateway": "",
   318                               "Bridge": "",
   319                               "PortMapping": null
   320                       },
   321                       "SysInitPath": "/home/kitty/go/src/github.com/docker/docker/bin/docker",
   322                       "ResolvConfPath": "/etc/resolv.conf",
   323                       "Volumes": {},
   324                       "HostConfig": {
   325                           "Binds": null,
   326                           "ContainerIDFile": "",
   327                           "LxcConf": [],
   328                           "Privileged": false,
   329                           "PortBindings": {
   330                              "80/tcp": [
   331                                  {
   332                                      "HostIp": "0.0.0.0",
   333                                      "HostPort": "49153"
   334                                  }
   335                              ]
   336                           },
   337                           "Links": ["/name:alias"],
   338                           "PublishAllPorts": false,
   339                           "CapAdd": ["NET_ADMIN"],
   340                           "CapDrop": ["MKNOD"]
   341                       }
   342          }
   343  
   344  Status Codes:
   345  
   346  -   **200** – no error
   347  -   **404** – no such container
   348  -   **500** – server error
   349  
   350  ### List processes running inside a container
   351  
   352  `GET /containers/(id)/top`
   353  
   354  List processes running inside the container `id`
   355  
   356  **Example request**:
   357  
   358          GET /containers/4fa6e0f0c678/top HTTP/1.1
   359  
   360  **Example response**:
   361  
   362          HTTP/1.1 200 OK
   363          Content-Type: application/json
   364  
   365          {
   366               "Titles": [
   367                       "USER",
   368                       "PID",
   369                       "%CPU",
   370                       "%MEM",
   371                       "VSZ",
   372                       "RSS",
   373                       "TTY",
   374                       "STAT",
   375                       "START",
   376                       "TIME",
   377                       "COMMAND"
   378                       ],
   379               "Processes": [
   380                       ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   381                       ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   382               ]
   383          }
   384  
   385  Query Parameters:
   386  
   387  -   **ps_args** – ps arguments to use (e.g., aux)
   388  
   389  Status Codes:
   390  
   391  -   **200** – no error
   392  -   **404** – no such container
   393  -   **500** – server error
   394  
   395  ### Get container logs
   396  
   397  `GET /containers/(id)/logs`
   398  
   399  Get stdout and stderr logs from the container ``id``
   400  
   401  **Example request**:
   402  
   403         GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10 HTTP/1.1
   404  
   405  **Example response**:
   406  
   407         HTTP/1.1 200 OK
   408         Content-Type: application/vnd.docker.raw-stream
   409  
   410         {{ STREAM }}
   411  
   412  Query Parameters:
   413  
   414  -   **follow** – 1/True/true or 0/False/false, return stream. Default false
   415  -   **stdout** – 1/True/true or 0/False/false, show stdout log. Default false
   416  -   **stderr** – 1/True/true or 0/False/false, show stderr log. Default false
   417  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   418          every log line. Default false
   419  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all
   420  
   421  Status Codes:
   422  
   423  -   **200** – no error
   424  -   **404** – no such container
   425  -   **500** – server error
   426  
   427  ### Inspect changes on a container's filesystem
   428  
   429  `GET /containers/(id)/changes`
   430  
   431  Inspect changes on container `id`'s filesystem
   432  
   433  **Example request**:
   434  
   435          GET /containers/4fa6e0f0c678/changes HTTP/1.1
   436  
   437  **Example response**:
   438  
   439          HTTP/1.1 200 OK
   440          Content-Type: application/json
   441  
   442          [
   443               {
   444                       "Path": "/dev",
   445                       "Kind": 0
   446               },
   447               {
   448                       "Path": "/dev/kmsg",
   449                       "Kind": 1
   450               },
   451               {
   452                       "Path": "/test",
   453                       "Kind": 1
   454               }
   455          ]
   456  
   457  Status Codes:
   458  
   459  -   **200** – no error
   460  -   **404** – no such container
   461  -   **500** – server error
   462  
   463  ### Export a container
   464  
   465  `GET /containers/(id)/export`
   466  
   467  Export the contents of container `id`
   468  
   469  **Example request**:
   470  
   471          GET /containers/4fa6e0f0c678/export HTTP/1.1
   472  
   473  **Example response**:
   474  
   475          HTTP/1.1 200 OK
   476          Content-Type: application/octet-stream
   477  
   478          {{ TAR STREAM }}
   479  
   480  Status Codes:
   481  
   482  -   **200** – no error
   483  -   **404** – no such container
   484  -   **500** – server error
   485  
   486  ### Resize a container TTY
   487  
   488  `GET /containers/(id)/resize?h=<height>&w=<width>`
   489  
   490  Resize the TTY of container `id`
   491  
   492  **Example request**:
   493  
   494          GET /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   495  
   496  **Example response**:
   497  
   498          HTTP/1.1 200 OK
   499          Content-Length: 0
   500          Content-Type: text/plain; charset=utf-8
   501  
   502  Status Codes:
   503  
   504  -   **200** – no error
   505  -   **404** – No such container
   506  -   **500** – bad file descriptor
   507  
   508  ### Start a container
   509  
   510  `POST /containers/(id)/start`
   511  
   512  Start the container `id`
   513  
   514  **Example request**:
   515  
   516          POST /containers/(id)/start HTTP/1.1
   517          Content-Type: application/json
   518  
   519          {
   520               "Binds": ["/tmp:/tmp"],
   521               "Links": ["redis3:redis"],
   522               "LxcConf": {"lxc.utsname":"docker"},
   523               "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   524               "PublishAllPorts": false,
   525               "Privileged": false,
   526               "Dns": ["8.8.8.8"],
   527               "DnsSearch": [""],
   528               "VolumesFrom": ["parent", "other:ro"],
   529               "CapAdd": ["NET_ADMIN"],
   530               "CapDrop": ["MKNOD"],
   531               "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   532               "NetworkMode": "bridge",
   533               "Devices": []
   534          }
   535  
   536  **Example response**:
   537  
   538          HTTP/1.1 204 No Content
   539  
   540  Json Parameters:
   541  
   542  -   **Binds** – A list of volume bindings for this container.  Each volume
   543          binding is a string of the form `container_path` (to create a new
   544          volume for the container), `host_path:container_path` (to bind-mount
   545          a host path into the container), or `host_path:container_path:ro`
   546          (to make the bind-mount read-only inside the container).
   547  -   **Links** - A list of links for the container.  Each link entry should be of
   548        of the form "container_name:alias".
   549  -   **LxcConf** - LXC specific configurations.  These configurations will only
   550        work when using the `lxc` execution driver.
   551  -   **PortBindings** - A map of exposed container ports and the host port they
   552        should map to. It should be specified in the form
   553        `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   554        Take note that `port` is specified as a string and not an integer value.
   555  -   **PublishAllPorts** - Allocates a random host port for all of a container's
   556        exposed ports. Specified as a boolean value.
   557  -   **Privileged** - Gives the container full access to the host.  Specified as
   558        a boolean value.
   559  -   **Dns** - A list of dns servers for the container to use.
   560  -   **DnsSearch** - A list of DNS search domains
   561  -   **VolumesFrom** - A list of volumes to inherit from another container.
   562        Specified in the form `<container name>[:<ro|rw>]`
   563  -   **CapAdd** - A list of kernel capabilities to add to the container.
   564  -   **Capdrop** - A list of kernel capabilities to drop from the container.
   565  -   **RestartPolicy** – The behavior to apply when the container exits.  The
   566          value is an object with a `Name` property of either `"always"` to
   567          always restart or `"on-failure"` to restart only when the container
   568          exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   569          controls the number of times to retry before giving up.
   570          The default is not to restart. (optional)
   571          An ever increasing delay (double the previous delay, starting at 100mS)
   572          is added before each restart to prevent flooding the server.
   573  -   **NetworkMode** - Sets the networking mode for the container. Supported
   574        values are: `bridge`, `host`, and `container:<name|id>`
   575  -   **Devices** - A list of devices to add to the container specified in the
   576        form
   577        `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   578  
   579  Status Codes:
   580  
   581  -   **204** – no error
   582  -   **304** – container already started
   583  -   **404** – no such container
   584  -   **500** – server error
   585  
   586  ### Stop a container
   587  
   588  `POST /containers/(id)/stop`
   589  
   590  Stop the container `id`
   591  
   592  **Example request**:
   593  
   594          POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   595  
   596  **Example response**:
   597  
   598          HTTP/1.1 204 No Content
   599  
   600  Query Parameters:
   601  
   602  -   **t** – number of seconds to wait before killing the container
   603  
   604  Status Codes:
   605  
   606  -   **204** – no error
   607  -   **304** – container already stopped
   608  -   **404** – no such container
   609  -   **500** – server error
   610  
   611  ### Restart a container
   612  
   613  `POST /containers/(id)/restart`
   614  
   615  Restart the container `id`
   616  
   617  **Example request**:
   618  
   619          POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   620  
   621  **Example response**:
   622  
   623          HTTP/1.1 204 No Content
   624  
   625  Query Parameters:
   626  
   627  -   **t** – number of seconds to wait before killing the container
   628  
   629  Status Codes:
   630  
   631  -   **204** – no error
   632  -   **404** – no such container
   633  -   **500** – server error
   634  
   635  ### Kill a container
   636  
   637  `POST /containers/(id)/kill`
   638  
   639  Kill the container `id`
   640  
   641  **Example request**:
   642  
   643          POST /containers/e90e34656806/kill HTTP/1.1
   644  
   645  **Example response**:
   646  
   647          HTTP/1.1 204 No Content
   648  
   649  Query Parameters
   650  
   651  -   **signal** - Signal to send to the container: integer or string like "SIGINT".
   652          When not set, SIGKILL is assumed and the call will waits for the container to exit.
   653  
   654  Status Codes:
   655  
   656  -   **204** – no error
   657  -   **404** – no such container
   658  -   **500** – server error
   659  
   660  ### Pause a container
   661  
   662  `POST /containers/(id)/pause`
   663  
   664  Pause the container `id`
   665  
   666  **Example request**:
   667  
   668          POST /containers/e90e34656806/pause HTTP/1.1
   669  
   670  **Example response**:
   671  
   672          HTTP/1.1 204 No Content
   673  
   674  Status Codes:
   675  
   676  -   **204** – no error
   677  -   **404** – no such container
   678  -   **500** – server error
   679  
   680  ### Unpause a container
   681  
   682  `POST /containers/(id)/unpause`
   683  
   684  Unpause the container `id`
   685  
   686  **Example request**:
   687  
   688          POST /containers/e90e34656806/unpause HTTP/1.1
   689  
   690  **Example response**:
   691  
   692          HTTP/1.1 204 No Content
   693  
   694  Status Codes:
   695  
   696  -   **204** – no error
   697  -   **404** – no such container
   698  -   **500** – server error
   699  
   700  ### Attach to a container
   701  
   702  `POST /containers/(id)/attach`
   703  
   704  Attach to the container `id`
   705  
   706  **Example request**:
   707  
   708          POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   709  
   710  **Example response**:
   711  
   712          HTTP/1.1 200 OK
   713          Content-Type: application/vnd.docker.raw-stream
   714  
   715          {{ STREAM }}
   716  
   717  Query Parameters:
   718  
   719  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   720  -   **stream** – 1/True/true or 0/False/false, return stream.
   721          Default false
   722  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   723          to stdin. Default false
   724  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   725          stdout log, if stream=true, attach to stdout. Default false
   726  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   727          stderr log, if stream=true, attach to stderr. Default false
   728  
   729  Status Codes:
   730  
   731  -   **200** – no error
   732  -   **400** – bad parameter
   733  -   **404** – no such container
   734  -   **500** – server error
   735  
   736      **Stream details**:
   737  
   738      When using the TTY setting is enabled in
   739      [`POST /containers/create`
   740      ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
   741      the stream is the raw data from the process PTY and client's stdin.
   742      When the TTY is disabled, then the stream is multiplexed to separate
   743      stdout and stderr.
   744  
   745      The format is a **Header** and a **Payload** (frame).
   746  
   747      **HEADER**
   748  
   749      The header will contain the information on which stream write the
   750      stream (stdout or stderr). It also contain the size of the
   751      associated frame encoded on the last 4 bytes (uint32).
   752  
   753      It is encoded on the first 8 bytes like this:
   754  
   755          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   756  
   757      `STREAM_TYPE` can be:
   758  
   759  -   0: stdin (will be written on stdout)
   760  -   1: stdout
   761  -   2: stderr
   762  
   763      `SIZE1, SIZE2, SIZE3, SIZE4` are the 4 bytes of
   764      the uint32 size encoded as big endian.
   765  
   766      **PAYLOAD**
   767  
   768      The payload is the raw stream.
   769  
   770      **IMPLEMENTATION**
   771  
   772      The simplest way to implement the Attach protocol is the following:
   773  
   774      1.  Read 8 bytes
   775      2.  chose stdout or stderr depending on the first byte
   776      3.  Extract the frame size from the last 4 bytes
   777      4.  Read the extracted size and output it on the correct output
   778      5.  Goto 1
   779  
   780  ### Attach to a container (websocket)
   781  
   782  `GET /containers/(id)/attach/ws`
   783  
   784  Attach to the container `id` via websocket
   785  
   786  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   787  
   788  **Example request**
   789  
   790          GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   791  
   792  **Example response**
   793  
   794          {{ STREAM }}
   795  
   796  Query Parameters:
   797  
   798  -   **logs** – 1/True/true or 0/False/false, return logs. Default false
   799  -   **stream** – 1/True/true or 0/False/false, return stream.
   800          Default false
   801  -   **stdin** – 1/True/true or 0/False/false, if stream=true, attach
   802          to stdin. Default false
   803  -   **stdout** – 1/True/true or 0/False/false, if logs=true, return
   804          stdout log, if stream=true, attach to stdout. Default false
   805  -   **stderr** – 1/True/true or 0/False/false, if logs=true, return
   806          stderr log, if stream=true, attach to stderr. Default false
   807  
   808  Status Codes:
   809  
   810  -   **200** – no error
   811  -   **400** – bad parameter
   812  -   **404** – no such container
   813  -   **500** – server error
   814  
   815  ### Wait a container
   816  
   817  `POST /containers/(id)/wait`
   818  
   819  Block until container `id` stops, then returns the exit code
   820  
   821  **Example request**:
   822  
   823          POST /containers/16253994b7c4/wait HTTP/1.1
   824  
   825  **Example response**:
   826  
   827          HTTP/1.1 200 OK
   828          Content-Type: application/json
   829  
   830          {"StatusCode": 0}
   831  
   832  Status Codes:
   833  
   834  -   **200** – no error
   835  -   **404** – no such container
   836  -   **500** – server error
   837  
   838  ### Remove a container
   839  
   840  `DELETE /containers/(id)`
   841  
   842  Remove the container `id` from the filesystem
   843  
   844  **Example request**:
   845  
   846          DELETE /containers/16253994b7c4?v=1 HTTP/1.1
   847  
   848  **Example response**:
   849  
   850          HTTP/1.1 204 No Content
   851  
   852  Query Parameters:
   853  
   854  -   **v** – 1/True/true or 0/False/false, Remove the volumes
   855          associated to the container. Default false
   856  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
   857          Default false
   858  
   859  Status Codes:
   860  
   861  -   **204** – no error
   862  -   **400** – bad parameter
   863  -   **404** – no such container
   864  -   **500** – server error
   865  
   866  ### Copy files or folders from a container
   867  
   868  `POST /containers/(id)/copy`
   869  
   870  Copy files or folders of container `id`
   871  
   872  **Example request**:
   873  
   874          POST /containers/4fa6e0f0c678/copy HTTP/1.1
   875          Content-Type: application/json
   876  
   877          {
   878               "Resource": "test.txt"
   879          }
   880  
   881  **Example response**:
   882  
   883          HTTP/1.1 200 OK
   884          Content-Type: application/x-tar
   885  
   886          {{ TAR STREAM }}
   887  
   888  Status Codes:
   889  
   890  -   **200** – no error
   891  -   **404** – no such container
   892  -   **500** – server error
   893  
   894  ## 2.2 Images
   895  
   896  ### List Images
   897  
   898  `GET /images/json`
   899  
   900  **Example request**:
   901  
   902          GET /images/json?all=0 HTTP/1.1
   903  
   904  **Example response**:
   905  
   906          HTTP/1.1 200 OK
   907          Content-Type: application/json
   908  
   909          [
   910            {
   911               "RepoTags": [
   912                 "ubuntu:12.04",
   913                 "ubuntu:precise",
   914                 "ubuntu:latest"
   915               ],
   916               "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
   917               "Created": 1365714795,
   918               "Size": 131506275,
   919               "VirtualSize": 131506275
   920            },
   921            {
   922               "RepoTags": [
   923                 "ubuntu:12.10",
   924                 "ubuntu:quantal"
   925               ],
   926               "ParentId": "27cf784147099545",
   927               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
   928               "Created": 1364102658,
   929               "Size": 24653,
   930               "VirtualSize": 180116135
   931            }
   932          ]
   933  
   934  
   935  Query Parameters:
   936  
   937  -   **all** – 1/True/true or 0/False/false, default false
   938  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
   939    -   dangling=true
   940  
   941  ### Create an image
   942  
   943  `POST /images/create`
   944  
   945  Create an image, either by pulling it from the registry or by importing it
   946  
   947  **Example request**:
   948  
   949          POST /images/create?fromImage=ubuntu HTTP/1.1
   950  
   951  **Example response**:
   952  
   953          HTTP/1.1 200 OK
   954          Content-Type: application/json
   955  
   956          {"status": "Pulling..."}
   957          {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
   958          {"error": "Invalid..."}
   959          ...
   960  
   961      When using this endpoint to pull an image from the registry, the
   962      `X-Registry-Auth` header can be used to include
   963      a base64-encoded AuthConfig object.
   964  
   965  Query Parameters:
   966  
   967  -   **fromImage** – name of the image to pull
   968  -   **fromSrc** – source to import.  The value may be a URL from which the image
   969          can be retrieved or `-` to read the image from the request body.
   970  -   **repo** – repository
   971  -   **tag** – tag
   972  -   **registry** – the registry to pull from
   973  
   974      Request Headers:
   975  
   976  -   **X-Registry-Auth** – base64-encoded AuthConfig object
   977  
   978  Status Codes:
   979  
   980  -   **200** – no error
   981  -   **500** – server error
   982  
   983  
   984  
   985  ### Inspect an image
   986  
   987  `GET /images/(name)/json`
   988  
   989  Return low-level information on the image `name`
   990  
   991  **Example request**:
   992  
   993          GET /images/ubuntu/json HTTP/1.1
   994  
   995  **Example response**:
   996  
   997          HTTP/1.1 200 OK
   998          Content-Type: application/json
   999  
  1000          {
  1001               "Created": "2013-03-23T22:24:18.818426-07:00",
  1002               "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1003               "ContainerConfig":
  1004                       {
  1005                               "Hostname": "",
  1006                               "User": "",
  1007                               "Memory": 0,
  1008                               "MemorySwap": 0,
  1009                               "AttachStdin": false,
  1010                               "AttachStdout": false,
  1011                               "AttachStderr": false,
  1012                               "PortSpecs": null,
  1013                               "Tty": true,
  1014                               "OpenStdin": true,
  1015                               "StdinOnce": false,
  1016                               "Env": null,
  1017                               "Cmd": ["/bin/bash"],
  1018                               "Dns": null,
  1019                               "Image": "ubuntu",
  1020                               "Volumes": null,
  1021                               "VolumesFrom": "",
  1022                               "WorkingDir": ""
  1023                       },
  1024               "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1025               "Parent": "27cf784147099545",
  1026               "Size": 6824592
  1027          }
  1028  
  1029  Status Codes:
  1030  
  1031  -   **200** – no error
  1032  -   **404** – no such image
  1033  -   **500** – server error
  1034  
  1035  ### Get the history of an image
  1036  
  1037  `GET /images/(name)/history`
  1038  
  1039  Return the history of the image `name`
  1040  
  1041  **Example request**:
  1042  
  1043          GET /images/ubuntu/history HTTP/1.1
  1044  
  1045  **Example response**:
  1046  
  1047          HTTP/1.1 200 OK
  1048          Content-Type: application/json
  1049  
  1050          [
  1051               {
  1052                       "Id": "b750fe79269d",
  1053                       "Created": 1364102658,
  1054                       "CreatedBy": "/bin/bash"
  1055               },
  1056               {
  1057                       "Id": "27cf78414709",
  1058                       "Created": 1364068391,
  1059                       "CreatedBy": ""
  1060               }
  1061          ]
  1062  
  1063  Status Codes:
  1064  
  1065  -   **200** – no error
  1066  -   **404** – no such image
  1067  -   **500** – server error
  1068  
  1069  ### Push an image on the registry
  1070  
  1071  `POST /images/(name)/push`
  1072  
  1073  Push the image `name` on the registry
  1074  
  1075  **Example request**:
  1076  
  1077          POST /images/test/push HTTP/1.1
  1078  
  1079  **Example response**:
  1080  
  1081          HTTP/1.1 200 OK
  1082          Content-Type: application/json
  1083  
  1084          {"status": "Pushing..."}
  1085          {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1086          {"error": "Invalid..."}
  1087          ...
  1088  
  1089      If you wish to push an image on to a private registry, that image must already have been tagged
  1090      into a repository which references that registry host name and port.  This repository name should
  1091      then be used in the URL. This mirrors the flow of the CLI.
  1092  
  1093  **Example request**:
  1094  
  1095          POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1096  
  1097  
  1098  Query Parameters:
  1099  
  1100  -   **tag** – the tag to associate with the image on the registry, optional
  1101  
  1102  Request Headers:
  1103  
  1104  -   **X-Registry-Auth** – include a base64-encoded AuthConfig
  1105          object.
  1106  
  1107  Status Codes:
  1108  
  1109  -   **200** – no error
  1110  -   **404** – no such image
  1111  -   **500** – server error
  1112  
  1113  ### Tag an image into a repository
  1114  
  1115  `POST /images/(name)/tag`
  1116  
  1117  Tag the image `name` into a repository
  1118  
  1119  **Example request**:
  1120  
  1121          POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1122  
  1123  **Example response**:
  1124  
  1125          HTTP/1.1 201 OK
  1126  
  1127  Query Parameters:
  1128  
  1129  -   **repo** – The repository to tag in
  1130  -   **force** – 1/True/true or 0/False/false, default false
  1131  -   **tag** - The new tag name
  1132  
  1133  Status Codes:
  1134  
  1135  -   **201** – no error
  1136  -   **400** – bad parameter
  1137  -   **404** – no such image
  1138  -   **409** – conflict
  1139  -   **500** – server error
  1140  
  1141  ### Remove an image
  1142  
  1143  `DELETE /images/(name)`
  1144  
  1145  Remove the image `name` from the filesystem
  1146  
  1147  **Example request**:
  1148  
  1149          DELETE /images/test HTTP/1.1
  1150  
  1151  **Example response**:
  1152  
  1153          HTTP/1.1 200 OK
  1154          Content-type: application/json
  1155  
  1156          [
  1157           {"Untagged": "3e2f21a89f"},
  1158           {"Deleted": "3e2f21a89f"},
  1159           {"Deleted": "53b4f83ac9"}
  1160          ]
  1161  
  1162  Query Parameters:
  1163  
  1164  -   **force** – 1/True/true or 0/False/false, default false
  1165  -   **noprune** – 1/True/true or 0/False/false, default false
  1166  
  1167  Status Codes:
  1168  
  1169  -   **200** – no error
  1170  -   **404** – no such image
  1171  -   **409** – conflict
  1172  -   **500** – server error
  1173  
  1174  ### Search images
  1175  
  1176  `GET /images/search`
  1177  
  1178  Search for an image on [Docker Hub](https://hub.docker.com).
  1179  
  1180  > **Note**:
  1181  > The response keys have changed from API v1.6 to reflect the JSON
  1182  > sent by the registry server to the docker daemon's request.
  1183  
  1184  **Example request**:
  1185  
  1186          GET /images/search?term=sshd HTTP/1.1
  1187  
  1188  **Example response**:
  1189  
  1190          HTTP/1.1 200 OK
  1191          Content-Type: application/json
  1192  
  1193          [
  1194                  {
  1195                      "description": "",
  1196                      "is_official": false,
  1197                      "is_automated": false,
  1198                      "name": "wma55/u1210sshd",
  1199                      "star_count": 0
  1200                  },
  1201                  {
  1202                      "description": "",
  1203                      "is_official": false,
  1204                      "is_automated": false,
  1205                      "name": "jdswinbank/sshd",
  1206                      "star_count": 0
  1207                  },
  1208                  {
  1209                      "description": "",
  1210                      "is_official": false,
  1211                      "is_automated": false,
  1212                      "name": "vgauthier/sshd",
  1213                      "star_count": 0
  1214                  }
  1215          ...
  1216          ]
  1217  
  1218  Query Parameters:
  1219  
  1220  -   **term** – term to search
  1221  
  1222  Status Codes:
  1223  
  1224  -   **200** – no error
  1225  -   **500** – server error
  1226  
  1227  ## 2.3 Misc
  1228  
  1229  ### Build an image from Dockerfile via stdin
  1230  
  1231  `POST /build`
  1232  
  1233  Build an image from Dockerfile via stdin
  1234  
  1235  **Example request**:
  1236  
  1237          POST /build HTTP/1.1
  1238  
  1239          {{ TAR STREAM }}
  1240  
  1241  **Example response**:
  1242  
  1243          HTTP/1.1 200 OK
  1244          Content-Type: application/json
  1245  
  1246          {"stream": "Step 1..."}
  1247          {"stream": "..."}
  1248          {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1249  
  1250      The stream must be a tar archive compressed with one of the
  1251      following algorithms: identity (no compression), gzip, bzip2, xz.
  1252  
  1253      The archive must include a file called `Dockerfile`
  1254      at its root. It may include any number of other files,
  1255      which will be accessible in the build context (See the [*ADD build
  1256      command*](/reference/builder/#dockerbuilder)).
  1257  
  1258  Query Parameters:
  1259  
  1260  -   **t** – repository name (and optionally a tag) to be applied to
  1261          the resulting image in case of success
  1262  -   **remote** – git or HTTP/HTTPS URI build source
  1263  -   **q** – suppress verbose build output
  1264  -   **nocache** – do not use the cache when building the image
  1265  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1266  -   **forcerm** - always remove intermediate containers (includes rm)
  1267  
  1268      Request Headers:
  1269  
  1270  -   **Content-type** – should be set to `"application/tar"`.
  1271  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1272  
  1273  Status Codes:
  1274  
  1275  -   **200** – no error
  1276  -   **500** – server error
  1277  
  1278  ### Check auth configuration
  1279  
  1280  `POST /auth`
  1281  
  1282  Get the default username and email
  1283  
  1284  **Example request**:
  1285  
  1286          POST /auth HTTP/1.1
  1287          Content-Type: application/json
  1288  
  1289          {
  1290               "username":" hannibal",
  1291               "password: "xxxx",
  1292               "email": "hannibal@a-team.com",
  1293               "serveraddress": "https://index.docker.io/v1/"
  1294          }
  1295  
  1296  **Example response**:
  1297  
  1298          HTTP/1.1 200 OK
  1299  
  1300  Status Codes:
  1301  
  1302  -   **200** – no error
  1303  -   **204** – no error
  1304  -   **500** – server error
  1305  
  1306  ### Display system-wide information
  1307  
  1308  `GET /info`
  1309  
  1310  Display system-wide information
  1311  
  1312  **Example request**:
  1313  
  1314          GET /info HTTP/1.1
  1315  
  1316  **Example response**:
  1317  
  1318          HTTP/1.1 200 OK
  1319          Content-Type: application/json
  1320  
  1321          {
  1322               "Containers": 11,
  1323               "Images": 16,
  1324               "Driver": "btrfs",
  1325               "ExecutionDriver": "native-0.1",
  1326               "KernelVersion": "3.12.0-1-amd64"
  1327               "Debug": false,
  1328               "NFd": 11,
  1329               "NGoroutines": 21,
  1330               "NEventsListener": 0,
  1331               "InitPath": "/usr/bin/docker",
  1332               "IndexServerAddress": ["https://index.docker.io/v1/"],
  1333               "MemoryLimit": true,
  1334               "SwapLimit": false,
  1335               "IPv4Forwarding": true
  1336          }
  1337  
  1338  Status Codes:
  1339  
  1340  -   **200** – no error
  1341  -   **500** – server error
  1342  
  1343  ### Show the docker version information
  1344  
  1345  `GET /version`
  1346  
  1347  Show the docker version information
  1348  
  1349  **Example request**:
  1350  
  1351          GET /version HTTP/1.1
  1352  
  1353  **Example response**:
  1354  
  1355          HTTP/1.1 200 OK
  1356          Content-Type: application/json
  1357  
  1358          {
  1359               "ApiVersion": "1.12",
  1360               "Version": "0.2.2",
  1361               "GitCommit": "5a2a5cc+CHANGES",
  1362               "GoVersion": "go1.0.3"
  1363          }
  1364  
  1365  Status Codes:
  1366  
  1367  -   **200** – no error
  1368  -   **500** – server error
  1369  
  1370  ### Ping the docker server
  1371  
  1372  `GET /_ping`
  1373  
  1374  Ping the docker server
  1375  
  1376  **Example request**:
  1377  
  1378          GET /_ping HTTP/1.1
  1379  
  1380  **Example response**:
  1381  
  1382          HTTP/1.1 200 OK
  1383          Content-Type: text/plain
  1384  
  1385          OK
  1386  
  1387  Status Codes:
  1388  
  1389  -   **200** - no error
  1390  -   **500** - server error
  1391  
  1392  ### Create a new image from a container's changes
  1393  
  1394  `POST /commit`
  1395  
  1396  Create a new image from a container's changes
  1397  
  1398  **Example request**:
  1399  
  1400          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1401          Content-Type: application/json
  1402  
  1403          {
  1404               "Hostname": "",
  1405               "Domainname": "",
  1406               "User": "",
  1407               "Memory": 0,
  1408               "MemorySwap": 0,
  1409               "CpuShares": 512,
  1410               "Cpuset": "0,1",
  1411               "AttachStdin": false,
  1412               "AttachStdout": true,
  1413               "AttachStderr": true,
  1414               "PortSpecs": null,
  1415               "Tty": false,
  1416               "OpenStdin": false,
  1417               "StdinOnce": false,
  1418               "Env": null,
  1419               "Cmd": [
  1420                       "date"
  1421               ],
  1422               "Volumes": {
  1423                       "/tmp": {}
  1424               },
  1425               "WorkingDir": "",
  1426               "NetworkDisabled": false,
  1427               "ExposedPorts": {
  1428                       "22/tcp": {}
  1429               }
  1430          }
  1431  
  1432  **Example response**:
  1433  
  1434          HTTP/1.1 201 Created
  1435          Content-Type: application/vnd.docker.raw-stream
  1436  
  1437          {"Id": "596069db4bf5"}
  1438  
  1439  Json Parameters:
  1440  
  1441  -  **config** - the container's configuration
  1442  
  1443  Query Parameters:
  1444  
  1445  -   **container** – source container
  1446  -   **repo** – repository
  1447  -   **tag** – tag
  1448  -   **comment** – commit message
  1449  -   **author** – author (e.g., "John Hannibal Smith
  1450      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1451  
  1452  Status Codes:
  1453  
  1454  -   **201** – no error
  1455  -   **404** – no such container
  1456  -   **500** – server error
  1457  
  1458  ### Monitor Docker's events
  1459  
  1460  `GET /events`
  1461  
  1462  Get container events from docker, either in real time via streaming, or via
  1463  polling (using since).
  1464  
  1465  Docker containers will report the following events:
  1466  
  1467      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1468  
  1469  and Docker images will report:
  1470  
  1471      untag, delete
  1472  
  1473  **Example request**:
  1474  
  1475          GET /events?since=1374067924
  1476  
  1477  **Example response**:
  1478  
  1479          HTTP/1.1 200 OK
  1480          Content-Type: application/json
  1481  
  1482          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1483          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1484          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1485          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1486  
  1487  Query Parameters:
  1488  
  1489  -   **since** – timestamp used for polling
  1490  -   **until** – timestamp used for polling
  1491  
  1492  Status Codes:
  1493  
  1494  -   **200** – no error
  1495  -   **500** – server error
  1496  
  1497  ### Get a tarball containing all images in a repository
  1498  
  1499  `GET /images/(name)/get`
  1500  
  1501  Get a tarball containing all images and metadata for the repository specified
  1502  by `name`.
  1503  
  1504  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1505  (and its parents) are returned. If `name` is an image ID, similarly only that
  1506  image (and its parents) are returned, but with the exclusion of the
  1507  'repositories' file in the tarball, as there were no image names referenced.
  1508  
  1509  See the [image tarball format](#image-tarball-format) for more details.
  1510  
  1511  **Example request**
  1512  
  1513          GET /images/ubuntu/get
  1514  
  1515  **Example response**:
  1516  
  1517          HTTP/1.1 200 OK
  1518          Content-Type: application/x-tar
  1519  
  1520          Binary data stream
  1521  
  1522  Status Codes:
  1523  
  1524  -   **200** – no error
  1525  -   **500** – server error
  1526  
  1527  ### Get a tarball containing all images.
  1528  
  1529  `GET /images/get`
  1530  
  1531  Get a tarball containing all images and metadata for one or more repositories.
  1532  
  1533  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1534  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1535  an image ID, similarly only that image (and its parents) are returned and there
  1536  would be no names referenced in the 'repositories' file for this image ID.
  1537  
  1538  See the [image tarball format](#image-tarball-format) for more details.
  1539  
  1540  **Example request**
  1541  
  1542          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1543  
  1544  **Example response**:
  1545  
  1546          HTTP/1.1 200 OK
  1547          Content-Type: application/x-tar
  1548  
  1549          Binary data stream
  1550  
  1551  Status Codes:
  1552  
  1553  -   **200** – no error
  1554  -   **500** – server error
  1555  
  1556  ### Load a tarball with a set of images and tags into docker
  1557  
  1558  `POST /images/load`
  1559  
  1560  Load a set of images and tags into the docker repository.
  1561  See the [image tarball format](#image-tarball-format) for more details.
  1562  
  1563  **Example request**
  1564  
  1565          POST /images/load
  1566  
  1567          Tarball in body
  1568  
  1569  **Example response**:
  1570  
  1571          HTTP/1.1 200 OK
  1572  
  1573  Status Codes:
  1574  
  1575  -   **200** – no error
  1576  -   **500** – server error
  1577  
  1578  ### Image tarball format
  1579  
  1580  An image tarball contains one directory per image layer (named using its long ID),
  1581  each containing three files:
  1582  
  1583  1. `VERSION`: currently `1.0` - the file format version
  1584  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1585  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1586  
  1587  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1588  for storing attribute changes and deletions.
  1589  
  1590  If the tarball defines a repository, there will also be a `repositories` file at
  1591  the root that contains a list of repository and tag names mapped to layer IDs.
  1592  
  1593  ```
  1594  {"hello-world":
  1595      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1596  }
  1597  ```
  1598  
  1599  ### Exec Create
  1600  
  1601  `POST /containers/(id)/exec`
  1602  
  1603  Sets up an exec instance in a running container `id`
  1604  
  1605  **Example request**:
  1606  
  1607          POST /containers/e90e34656806/exec HTTP/1.1
  1608          Content-Type: application/json
  1609  
  1610          {
  1611  	     "AttachStdin": false,
  1612  	     "AttachStdout": true,
  1613  	     "AttachStderr": true,
  1614  	     "Tty": false,
  1615  	     "Cmd": [
  1616                       "date"
  1617               ],
  1618          }
  1619  
  1620  **Example response**:
  1621  
  1622          HTTP/1.1 201 OK
  1623          Content-Type: application/json
  1624  
  1625          {
  1626               "Id": "f90e34656806"
  1627          }
  1628  
  1629  Json Parameters:
  1630  
  1631  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1632  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1633  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1634  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1635  -   **Cmd** - Command to run specified as a string or an array of strings.
  1636  
  1637  
  1638  Status Codes:
  1639  
  1640  -   **201** – no error
  1641  -   **404** – no such container
  1642  
  1643  ### Exec Start
  1644  
  1645  `POST /exec/(id)/start`
  1646  
  1647  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1648  returns after starting the `exec` command. Otherwise, this API sets up an
  1649  interactive session with the `exec` command.
  1650  
  1651  **Example request**:
  1652  
  1653          POST /exec/e90e34656806/start HTTP/1.1
  1654          Content-Type: application/json
  1655  
  1656          {
  1657  	     "Detach": false,
  1658  	     "Tty": false,
  1659          }
  1660  
  1661  **Example response**:
  1662  
  1663          HTTP/1.1 201 OK
  1664          Content-Type: application/json
  1665  
  1666          {{ STREAM }}
  1667  
  1668  Json Parameters:
  1669  
  1670  -   **Detach** - Detach from the exec command
  1671  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1672  
  1673  Status Codes:
  1674  
  1675  -   **201** – no error
  1676  -   **404** – no such exec instance
  1677  
  1678      **Stream details**:
  1679      Similar to the stream behavior of `POST /container/(id)/attach` API
  1680  
  1681  ### Exec Resize
  1682  
  1683  `POST /exec/(id)/resize`
  1684  
  1685  Resizes the tty session used by the exec command `id`.
  1686  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1687  
  1688  **Example request**:
  1689  
  1690          POST /exec/e90e34656806/resize HTTP/1.1
  1691          Content-Type: plain/text
  1692  
  1693  **Example response**:
  1694  
  1695          HTTP/1.1 201 OK
  1696          Content-Type: plain/text
  1697  
  1698  Query Parameters:
  1699  
  1700  -   **h** – height of tty session
  1701  -   **w** – width
  1702  
  1703  Status Codes:
  1704  
  1705  -   **201** – no error
  1706  -   **404** – no such exec instance
  1707  
  1708  # 3. Going further
  1709  
  1710  ## 3.1 Inside `docker run`
  1711  
  1712  As an example, the `docker run` command line makes the following API calls:
  1713  
  1714  - Create the container
  1715  
  1716  - If the status code is 404, it means the image doesn't exist:
  1717      - Try to pull it
  1718      - Then retry to create the container
  1719  
  1720  - Start the container
  1721  
  1722  - If you are not in detached mode:
  1723  - Attach to the container, using logs=1 (to have stdout and
  1724        stderr from the container's start) and stream=1
  1725  
  1726  - If in detached mode or only stdin is attached:
  1727  - Display the container's id
  1728  
  1729  ## 3.2 Hijacking
  1730  
  1731  In this version of the API, /attach, uses hijacking to transport stdin,
  1732  stdout and stderr on the same socket. This might change in the future.
  1733  
  1734  ## 3.3 CORS Requests
  1735  
  1736  To enable cross origin requests to the remote api add the flag
  1737  "--api-enable-cors" when running docker in daemon mode.
  1738  
  1739      $ docker -d -H="192.168.1.9:2375" --api-enable-cors