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

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