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

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.16"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent = "smn_remoteapi"
     8  weight = 5
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.16
    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":"e90e34656806"
   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  `POST /containers/(id)/resize?h=<height>&w=<width>`
   489  
   490  Resize the TTY for container with  `id`. The container must be restarted for the resize to take effect.
   491  
   492  **Example request**:
   493  
   494          POST /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** – Cannot resize container
   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  -   **pull** - attempt to pull the image even if an older image exists locally
  1266  -   **rm** - remove intermediate containers after a successful build (default behavior)
  1267  -   **forcerm** - always remove intermediate containers (includes rm)
  1268  
  1269      Request Headers:
  1270  
  1271  -   **Content-type** – should be set to `"application/tar"`.
  1272  -   **X-Registry-Config** – base64-encoded ConfigFile object
  1273  
  1274  Status Codes:
  1275  
  1276  -   **200** – no error
  1277  -   **500** – server error
  1278  
  1279  ### Check auth configuration
  1280  
  1281  `POST /auth`
  1282  
  1283  Get the default username and email
  1284  
  1285  **Example request**:
  1286  
  1287          POST /auth HTTP/1.1
  1288          Content-Type: application/json
  1289  
  1290          {
  1291               "username":" hannibal",
  1292               "password: "xxxx",
  1293               "email": "hannibal@a-team.com",
  1294               "serveraddress": "https://index.docker.io/v1/"
  1295          }
  1296  
  1297  **Example response**:
  1298  
  1299          HTTP/1.1 200 OK
  1300  
  1301  Status Codes:
  1302  
  1303  -   **200** – no error
  1304  -   **204** – no error
  1305  -   **500** – server error
  1306  
  1307  ### Display system-wide information
  1308  
  1309  `GET /info`
  1310  
  1311  Display system-wide information
  1312  
  1313  **Example request**:
  1314  
  1315          GET /info HTTP/1.1
  1316  
  1317  **Example response**:
  1318  
  1319          HTTP/1.1 200 OK
  1320          Content-Type: application/json
  1321  
  1322          {
  1323               "Containers":11,
  1324               "Images":16,
  1325               "Driver":"btrfs",
  1326               "DriverStatus": [[""]],
  1327               "ExecutionDriver":"native-0.1",
  1328               "KernelVersion":"3.12.0-1-amd64"
  1329               "NCPU":1,
  1330               "MemTotal":2099236864,
  1331               "Name":"prod-server-42",
  1332               "ID":"7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1333               "Debug":false,
  1334               "NFd": 11,
  1335               "NGoroutines":21,
  1336               "NEventsListener":0,
  1337               "InitPath":"/usr/bin/docker",
  1338               "InitSha1":"",
  1339               "IndexServerAddress":["https://index.docker.io/v1/"],
  1340               "MemoryLimit":true,
  1341               "SwapLimit":false,
  1342               "IPv4Forwarding":true,
  1343               "Labels":["storage=ssd"],
  1344               "DockerRootDir": "/var/lib/docker",
  1345               "OperatingSystem": "Boot2Docker",
  1346          }
  1347  
  1348  Status Codes:
  1349  
  1350  -   **200** – no error
  1351  -   **500** – server error
  1352  
  1353  ### Show the docker version information
  1354  
  1355  `GET /version`
  1356  
  1357  Show the docker version information
  1358  
  1359  **Example request**:
  1360  
  1361          GET /version HTTP/1.1
  1362  
  1363  **Example response**:
  1364  
  1365          HTTP/1.1 200 OK
  1366          Content-Type: application/json
  1367  
  1368          {
  1369               "ApiVersion": "1.12",
  1370               "Version": "0.2.2",
  1371               "GitCommit": "5a2a5cc+CHANGES",
  1372               "GoVersion": "go1.0.3"
  1373          }
  1374  
  1375  Status Codes:
  1376  
  1377  -   **200** – no error
  1378  -   **500** – server error
  1379  
  1380  ### Ping the docker server
  1381  
  1382  `GET /_ping`
  1383  
  1384  Ping the docker server
  1385  
  1386  **Example request**:
  1387  
  1388          GET /_ping HTTP/1.1
  1389  
  1390  **Example response**:
  1391  
  1392          HTTP/1.1 200 OK
  1393          Content-Type: text/plain
  1394  
  1395          OK
  1396  
  1397  Status Codes:
  1398  
  1399  -   **200** - no error
  1400  -   **500** - server error
  1401  
  1402  ### Create a new image from a container's changes
  1403  
  1404  `POST /commit`
  1405  
  1406  Create a new image from a container's changes
  1407  
  1408  **Example request**:
  1409  
  1410          POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1411          Content-Type: application/json
  1412  
  1413          {
  1414               "Hostname": "",
  1415               "Domainname": "",
  1416               "User": "",
  1417               "Memory": 0,
  1418               "MemorySwap": 0,
  1419               "CpuShares": 512,
  1420               "Cpuset": "0,1",
  1421               "AttachStdin": false,
  1422               "AttachStdout": true,
  1423               "AttachStderr": true,
  1424               "PortSpecs": null,
  1425               "Tty": false,
  1426               "OpenStdin": false,
  1427               "StdinOnce": false,
  1428               "Env": null,
  1429               "Cmd": [
  1430                       "date"
  1431               ],
  1432               "Volumes": {
  1433                       "/tmp": {}
  1434               },
  1435               "WorkingDir": "",
  1436               "NetworkDisabled": false,
  1437               "ExposedPorts": {
  1438                       "22/tcp": {}
  1439               }
  1440          }
  1441  
  1442  **Example response**:
  1443  
  1444          HTTP/1.1 201 Created
  1445          Content-Type: application/vnd.docker.raw-stream
  1446  
  1447          {"Id": "596069db4bf5"}
  1448  
  1449  Json Parameters:
  1450  
  1451  -  **config** - the container's configuration
  1452  
  1453  Query Parameters:
  1454  
  1455  -   **container** – source container
  1456  -   **repo** – repository
  1457  -   **tag** – tag
  1458  -   **comment** – commit message
  1459  -   **author** – author (e.g., "John Hannibal Smith
  1460      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1461  
  1462  Status Codes:
  1463  
  1464  -   **201** – no error
  1465  -   **404** – no such container
  1466  -   **500** – server error
  1467  
  1468  ### Monitor Docker's events
  1469  
  1470  `GET /events`
  1471  
  1472  Get container events from docker, either in real time via streaming, or via
  1473  polling (using since).
  1474  
  1475  Docker containers will report the following events:
  1476  
  1477      create, destroy, die, export, kill, pause, restart, start, stop, unpause
  1478  
  1479  and Docker images will report:
  1480  
  1481      untag, delete
  1482  
  1483  **Example request**:
  1484  
  1485          GET /events?since=1374067924
  1486  
  1487  **Example response**:
  1488  
  1489          HTTP/1.1 200 OK
  1490          Content-Type: application/json
  1491  
  1492          {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1493          {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1494          {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1495          {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1496  
  1497  Query Parameters:
  1498  
  1499  -   **since** – timestamp used for polling
  1500  -   **until** – timestamp used for polling
  1501  -   **filters** – a json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1502    -   event=&lt;string&gt; -- event to filter
  1503    -   image=&lt;string&gt; -- image to filter
  1504    -   container=&lt;string&gt; -- container to filter
  1505  
  1506  Status Codes:
  1507  
  1508  -   **200** – no error
  1509  -   **500** – server error
  1510  
  1511  ### Get a tarball containing all images in a repository
  1512  
  1513  `GET /images/(name)/get`
  1514  
  1515  Get a tarball containing all images and metadata for the repository specified
  1516  by `name`.
  1517  
  1518  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1519  (and its parents) are returned. If `name` is an image ID, similarly only that
  1520  image (and its parents) are returned, but with the exclusion of the
  1521  'repositories' file in the tarball, as there were no image names referenced.
  1522  
  1523  See the [image tarball format](#image-tarball-format) for more details.
  1524  
  1525  **Example request**
  1526  
  1527          GET /images/ubuntu/get
  1528  
  1529  **Example response**:
  1530  
  1531          HTTP/1.1 200 OK
  1532          Content-Type: application/x-tar
  1533  
  1534          Binary data stream
  1535  
  1536  Status Codes:
  1537  
  1538  -   **200** – no error
  1539  -   **500** – server error
  1540  
  1541  ### Get a tarball containing all images.
  1542  
  1543  `GET /images/get`
  1544  
  1545  Get a tarball containing all images and metadata for one or more repositories.
  1546  
  1547  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1548  ubuntu:latest), then only that image (and its parents) are returned; if it is
  1549  an image ID, similarly only that image (and its parents) are returned and there
  1550  would be no names referenced in the 'repositories' file for this image ID.
  1551  
  1552  See the [image tarball format](#image-tarball-format) for more details.
  1553  
  1554  **Example request**
  1555  
  1556          GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1557  
  1558  **Example response**:
  1559  
  1560          HTTP/1.1 200 OK
  1561          Content-Type: application/x-tar
  1562  
  1563          Binary data stream
  1564  
  1565  Status Codes:
  1566  
  1567  -   **200** – no error
  1568  -   **500** – server error
  1569  
  1570  ### Load a tarball with a set of images and tags into docker
  1571  
  1572  `POST /images/load`
  1573  
  1574  Load a set of images and tags into the docker repository.
  1575  See the [image tarball format](#image-tarball-format) for more details.
  1576  
  1577  **Example request**
  1578  
  1579          POST /images/load
  1580  
  1581          Tarball in body
  1582  
  1583  **Example response**:
  1584  
  1585          HTTP/1.1 200 OK
  1586  
  1587  Status Codes:
  1588  
  1589  -   **200** – no error
  1590  -   **500** – server error
  1591  
  1592  ### Image tarball format
  1593  
  1594  An image tarball contains one directory per image layer (named using its long ID),
  1595  each containing three files:
  1596  
  1597  1. `VERSION`: currently `1.0` - the file format version
  1598  2. `json`: detailed layer information, similar to `docker inspect layer_id`
  1599  3. `layer.tar`: A tarfile containing the filesystem changes in this layer
  1600  
  1601  The `layer.tar` file will contain `aufs` style `.wh..wh.aufs` files and directories
  1602  for storing attribute changes and deletions.
  1603  
  1604  If the tarball defines a repository, there will also be a `repositories` file at
  1605  the root that contains a list of repository and tag names mapped to layer IDs.
  1606  
  1607  ```
  1608  {"hello-world":
  1609      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  1610  }
  1611  ```
  1612  
  1613  ### Exec Create
  1614  
  1615  `POST /containers/(id)/exec`
  1616  
  1617  Sets up an exec instance in a running container `id`
  1618  
  1619  **Example request**:
  1620  
  1621          POST /containers/e90e34656806/exec HTTP/1.1
  1622          Content-Type: application/json
  1623  
  1624          {
  1625  	     "AttachStdin": false,
  1626  	     "AttachStdout": true,
  1627  	     "AttachStderr": true,
  1628  	     "Tty": false,
  1629  	     "Cmd": [
  1630                       "date"
  1631               ],
  1632          }
  1633  
  1634  **Example response**:
  1635  
  1636          HTTP/1.1 201 OK
  1637          Content-Type: application/json
  1638  
  1639          {
  1640               "Id": "f90e34656806"
  1641          }
  1642  
  1643  Json Parameters:
  1644  
  1645  -   **AttachStdin** - Boolean value, attaches to stdin of the exec command.
  1646  -   **AttachStdout** - Boolean value, attaches to stdout of the exec command.
  1647  -   **AttachStderr** - Boolean value, attaches to stderr of the exec command.
  1648  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1649  -   **Cmd** - Command to run specified as a string or an array of strings.
  1650  
  1651  
  1652  Status Codes:
  1653  
  1654  -   **201** – no error
  1655  -   **404** – no such container
  1656  
  1657  ### Exec Start
  1658  
  1659  `POST /exec/(id)/start`
  1660  
  1661  Starts a previously set up exec instance `id`. If `detach` is true, this API
  1662  returns after starting the `exec` command. Otherwise, this API sets up an
  1663  interactive session with the `exec` command.
  1664  
  1665  **Example request**:
  1666  
  1667          POST /exec/e90e34656806/start HTTP/1.1
  1668          Content-Type: application/json
  1669  
  1670          {
  1671  	     "Detach": false,
  1672  	     "Tty": false,
  1673          }
  1674  
  1675  **Example response**:
  1676  
  1677          HTTP/1.1 201 OK
  1678          Content-Type: application/json
  1679  
  1680          {{ STREAM }}
  1681  
  1682  Json Parameters:
  1683  
  1684  -   **Detach** - Detach from the exec command
  1685  -   **Tty** - Boolean value to allocate a pseudo-TTY
  1686  
  1687  Status Codes:
  1688  
  1689  -   **201** – no error
  1690  -   **404** – no such exec instance
  1691  
  1692      **Stream details**:
  1693      Similar to the stream behavior of `POST /container/(id)/attach` API
  1694  
  1695  ### Exec Resize
  1696  
  1697  `POST /exec/(id)/resize`
  1698  
  1699  Resizes the tty session used by the exec command `id`.
  1700  This API is valid only if `tty` was specified as part of creating and starting the exec command.
  1701  
  1702  **Example request**:
  1703  
  1704          POST /exec/e90e34656806/resize HTTP/1.1
  1705          Content-Type: plain/text
  1706  
  1707  **Example response**:
  1708  
  1709          HTTP/1.1 201 OK
  1710          Content-Type: plain/text
  1711  
  1712  Query Parameters:
  1713  
  1714  -   **h** – height of tty session
  1715  -   **w** – width
  1716  
  1717  Status Codes:
  1718  
  1719  -   **201** – no error
  1720  -   **404** – no such exec instance
  1721  
  1722  ### Exec Inspect
  1723  
  1724  `GET /exec/(id)/json`
  1725  
  1726  Return low-level information about the exec command `id`.
  1727  
  1728  **Example request**:
  1729  
  1730          GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  1731  
  1732  **Example response**:
  1733  
  1734          HTTP/1.1 200 OK
  1735          Content-Type: plain/text
  1736  
  1737          {
  1738            "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  1739            "Running" : false,
  1740            "ExitCode" : 2,
  1741            "ProcessConfig" : {
  1742              "privileged" : false,
  1743              "user" : "",
  1744              "tty" : false,
  1745              "entrypoint" : "sh",
  1746              "arguments" : [
  1747                "-c",
  1748                "exit 2"
  1749              ]
  1750            },
  1751            "OpenStdin" : false,
  1752            "OpenStderr" : false,
  1753            "OpenStdout" : false,
  1754            "Container" : {
  1755              "State" : {
  1756                "Running" : true,
  1757                "Paused" : false,
  1758                "Restarting" : false,
  1759                "OOMKilled" : false,
  1760                "Pid" : 3650,
  1761                "ExitCode" : 0,
  1762                "Error" : "",
  1763                "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  1764                "FinishedAt" : "0001-01-01T00:00:00Z"
  1765              },
  1766              "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  1767              "Created" : "2014-11-17T22:26:03.626304998Z",
  1768              "Path" : "date",
  1769              "Args" : [],
  1770              "Config" : {
  1771                "Hostname" : "8f177a186b97",
  1772                "Domainname" : "",
  1773                "User" : "",
  1774                "Memory" : 0,
  1775                "MemorySwap" : 0,
  1776                "CpuShares" : 0,
  1777                "Cpuset" : "",
  1778                "AttachStdin" : false,
  1779                "AttachStdout" : false,
  1780                "AttachStderr" : false,
  1781                "PortSpecs" : null,
  1782                "ExposedPorts" : null,
  1783                "Tty" : false,
  1784                "OpenStdin" : false,
  1785                "StdinOnce" : false,
  1786                "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  1787                "Cmd" : [
  1788                  "date"
  1789                ],
  1790                "Image" : "ubuntu",
  1791                "Volumes" : null,
  1792                "WorkingDir" : "",
  1793                "Entrypoint" : null,
  1794                "NetworkDisabled" : false,
  1795                "MacAddress" : "",
  1796                "OnBuild" : null,
  1797                "SecurityOpt" : null
  1798              },
  1799              "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  1800              "NetworkSettings" : {
  1801                "IPAddress" : "172.17.0.2",
  1802                "IPPrefixLen" : 16,
  1803                "MacAddress" : "02:42:ac:11:00:02",
  1804                "Gateway" : "172.17.42.1",
  1805                "Bridge" : "docker0",
  1806                "PortMapping" : null,
  1807                "Ports" : {}
  1808              },
  1809              "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  1810              "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  1811              "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  1812              "Name" : "/test",
  1813              "Driver" : "aufs",
  1814              "ExecDriver" : "native-0.2",
  1815              "MountLabel" : "",
  1816              "ProcessLabel" : "",
  1817              "AppArmorProfile" : "",
  1818              "RestartCount" : 0,
  1819              "Volumes" : {},
  1820              "VolumesRW" : {}
  1821            }
  1822          }
  1823  
  1824  Status Codes:
  1825  
  1826  -   **200** – no error
  1827  -   **404** – no such exec instance
  1828  -   **500** - server error
  1829  
  1830  # 3. Going further
  1831  
  1832  ## 3.1 Inside `docker run`
  1833  
  1834  As an example, the `docker run` command line makes the following API calls:
  1835  
  1836  - Create the container
  1837  
  1838  - If the status code is 404, it means the image doesn't exist:
  1839      - Try to pull it
  1840      - Then retry to create the container
  1841  
  1842  - Start the container
  1843  
  1844  - If you are not in detached mode:
  1845  - Attach to the container, using logs=1 (to have stdout and
  1846        stderr from the container's start) and stream=1
  1847  
  1848  - If in detached mode or only stdin is attached:
  1849  - Display the container's id
  1850  
  1851  ## 3.2 Hijacking
  1852  
  1853  In this version of the API, /attach, uses hijacking to transport stdin,
  1854  stdout and stderr on the same socket. This might change in the future.
  1855  
  1856  ## 3.3 CORS Requests
  1857  
  1858  To enable cross origin requests to the remote api add the flag
  1859  "--api-enable-cors" when running docker in daemon mode.
  1860  
  1861      $ docker -d -H="192.168.1.9:2375" --api-enable-cors