github.com/mheon/docker@v0.11.2-0.20150922122814-44f47903a831/docs/reference/api/docker_remote_api_v1.20.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Remote API v1.20"
     4  description = "API Documentation for Docker"
     5  keywords = ["API, Docker, rcli, REST,  documentation"]
     6  [menu.main]
     7  parent="smn_remoteapi"
     8  weight = 1
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Docker Remote API v1.20
    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. However, for some complex commands, like `attach`
    21     or `pull`, the HTTP connection is hijacked to transport `stdout`,
    22     `stdin` and `stderr`.
    23   - When the client API version is newer than the daemon's, these calls return an HTTP
    24     `400 Bad Request` error message.
    25  
    26  # 2. Endpoints
    27  
    28  ## 2.1 Containers
    29  
    30  ### List containers
    31  
    32  `GET /containers/json`
    33  
    34  List containers
    35  
    36  **Example request**:
    37  
    38      GET /containers/json?all=1&before=8dfafdbc3a40&size=1 HTTP/1.1
    39  
    40  **Example response**:
    41  
    42      HTTP/1.1 200 OK
    43      Content-Type: application/json
    44  
    45      [
    46           {
    47                   "Id": "8dfafdbc3a40",
    48                   "Names":["/boring_feynman"],
    49                   "Image": "ubuntu:latest",
    50                   "Command": "echo 1",
    51                   "Created": 1367854155,
    52                   "Status": "Exit 0",
    53                   "Ports": [{"PrivatePort": 2222, "PublicPort": 3333, "Type": "tcp"}],
    54                   "Labels": {
    55                           "com.example.vendor": "Acme",
    56                           "com.example.license": "GPL",
    57                           "com.example.version": "1.0"
    58                   },
    59                   "SizeRw": 12288,
    60                   "SizeRootFs": 0
    61           },
    62           {
    63                   "Id": "9cd87474be90",
    64                   "Names":["/coolName"],
    65                   "Image": "ubuntu:latest",
    66                   "Command": "echo 222222",
    67                   "Created": 1367854155,
    68                   "Status": "Exit 0",
    69                   "Ports": [],
    70                   "Labels": {},
    71                   "SizeRw": 12288,
    72                   "SizeRootFs": 0
    73           },
    74           {
    75                   "Id": "3176a2479c92",
    76                   "Names":["/sleepy_dog"],
    77                   "Image": "ubuntu:latest",
    78                   "Command": "echo 3333333333333333",
    79                   "Created": 1367854154,
    80                   "Status": "Exit 0",
    81                   "Ports":[],
    82                   "Labels": {},
    83                   "SizeRw":12288,
    84                   "SizeRootFs":0
    85           },
    86           {
    87                   "Id": "4cb07b47f9fb",
    88                   "Names":["/running_cat"],
    89                   "Image": "ubuntu:latest",
    90                   "Command": "echo 444444444444444444444444444444444",
    91                   "Created": 1367854152,
    92                   "Status": "Exit 0",
    93                   "Ports": [],
    94                   "Labels": {},
    95                   "SizeRw": 12288,
    96                   "SizeRootFs": 0
    97           }
    98      ]
    99  
   100  Query Parameters:
   101  
   102  -   **all** – 1/True/true or 0/False/false, Show all containers.
   103          Only running containers are shown by default (i.e., this defaults to false)
   104  -   **limit** – Show `limit` last created
   105          containers, include non-running ones.
   106  -   **since** – Show only containers created since Id, include
   107          non-running ones.
   108  -   **before** – Show only containers created before Id, include
   109          non-running ones.
   110  -   **size** – 1/True/true or 0/False/false, Show the containers
   111          sizes
   112  -   **filters** - a JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
   113    -   `exited=<int>`; -- containers with exit code of  `<int>` ;
   114    -   `status=`(`created`|`restarting`|`running`|`paused`|`exited`)
   115    -   `label=key` or `label="key=value"` of a container label
   116  
   117  Status Codes:
   118  
   119  -   **200** – no error
   120  -   **400** – bad parameter
   121  -   **500** – server error
   122  
   123  ### Create a container
   124  
   125  `POST /containers/create`
   126  
   127  Create a container
   128  
   129  **Example request**:
   130  
   131      POST /containers/create HTTP/1.1
   132      Content-Type: application/json
   133  
   134      {
   135             "Hostname": "",
   136             "Domainname": "",
   137             "User": "",
   138             "AttachStdin": false,
   139             "AttachStdout": true,
   140             "AttachStderr": true,
   141             "Tty": false,
   142             "OpenStdin": false,
   143             "StdinOnce": false,
   144             "Env": null,
   145             "Cmd": [
   146                     "date"
   147             ],
   148             "Entrypoint": "",
   149             "Image": "ubuntu",
   150             "Labels": {
   151                     "com.example.vendor": "Acme",
   152                     "com.example.license": "GPL",
   153                     "com.example.version": "1.0"
   154             },
   155             "Mounts": [
   156               {
   157                 "Source": "/data",
   158                 "Destination": "/data",
   159                 "Mode": "ro,Z",
   160                 "RW": false
   161               }
   162             ],
   163             "WorkingDir": "",
   164             "NetworkDisabled": false,
   165             "MacAddress": "12:34:56:78:9a:bc",
   166             "ExposedPorts": {
   167                     "22/tcp": {}
   168             },
   169             "HostConfig": {
   170               "Binds": ["/tmp:/tmp"],
   171               "Links": ["redis3:redis"],
   172               "LxcConf": {"lxc.utsname":"docker"},
   173               "Memory": 0,
   174               "MemorySwap": 0,
   175               "CpuShares": 512,
   176               "CpuPeriod": 100000,
   177               "CpusetCpus": "0,1",
   178               "CpusetMems": "0,1",
   179               "BlkioWeight": 300,
   180               "MemorySwappiness": 60,
   181               "OomKillDisable": false,
   182               "PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
   183               "PublishAllPorts": false,
   184               "Privileged": false,
   185               "ReadonlyRootfs": false,
   186               "Dns": ["8.8.8.8"],
   187               "DnsSearch": [""],
   188               "ExtraHosts": null,
   189               "VolumesFrom": ["parent", "other:ro"],
   190               "CapAdd": ["NET_ADMIN"],
   191               "CapDrop": ["MKNOD"],
   192               "RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
   193               "NetworkMode": "bridge",
   194               "Devices": [],
   195               "Ulimits": [{}],
   196               "LogConfig": { "Type": "json-file", "Config": {} },
   197               "SecurityOpt": [""],
   198               "CgroupParent": ""
   199            }
   200        }
   201  
   202  **Example response**:
   203  
   204        HTTP/1.1 201 Created
   205        Content-Type: application/json
   206  
   207        {
   208             "Id":"e90e34656806",
   209             "Warnings":[]
   210        }
   211  
   212  Json Parameters:
   213  
   214  -   **Hostname** - A string value containing the hostname to use for the
   215        container.
   216  -   **Domainname** - A string value containing the domain name to use
   217        for the container.
   218  -   **User** - A string value specifying the user inside the container.
   219  -   **Memory** - Memory limit in bytes.
   220  -   **MemorySwap**- Total memory limit (memory + swap); set `-1` to disable swap
   221        You must use this with `memory` and make the swap value larger than `memory`.
   222  -   **CpuShares** - An integer value containing the container's CPU Shares
   223        (ie. the relative weight vs other containers).
   224  -   **CpuPeriod** - The length of a CPU period in microseconds.
   225  -   **Cpuset** - Deprecated please don't use. Use `CpusetCpus` instead. 
   226  -   **CpusetCpus** - String value containing the `cgroups CpusetCpus` to use.
   227  -   **CpusetMems** - Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.
   228  -   **BlkioWeight** - Block IO weight (relative weight) accepts a weight value between 10 and 1000.
   229  -   **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
   230  -   **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
   231  -   **AttachStdin** - Boolean value, attaches to `stdin`.
   232  -   **AttachStdout** - Boolean value, attaches to `stdout`.
   233  -   **AttachStderr** - Boolean value, attaches to `stderr`.
   234  -   **Tty** - Boolean value, Attach standard streams to a `tty`, including `stdin` if it is not closed.
   235  -   **OpenStdin** - Boolean value, opens stdin,
   236  -   **StdinOnce** - Boolean value, close `stdin` after the 1 attached client disconnects.
   237  -   **Env** - A list of environment variables in the form of `VAR=value`
   238  -   **Labels** - Adds a map of labels to a container. To specify a map: `{"key":"value"[,"key2":"value2"]}`
   239  -   **Cmd** - Command to run specified as a string or an array of strings.
   240  -   **Entrypoint** - Set the entry point for the container as a string or an array
   241        of strings.
   242  -   **Image** - A string specifying the image name to use for the container.
   243  -   **Mounts** - An array of mount points in the container.
   244  -   **WorkingDir** - A string specifying the working directory for commands to
   245        run in.
   246  -   **NetworkDisabled** - Boolean value, when true disables networking for the
   247        container
   248  -   **ExposedPorts** - An object mapping ports to an empty object in the form of:
   249        `"ExposedPorts": { "<port>/<tcp|udp>: {}" }`
   250  -   **HostConfig**
   251      -   **Binds** – A list of volume bindings for this container. Each volume binding is a string in one of these forms:
   252             + `container_path` to create a new volume for the container
   253             + `host_path:container_path` to bind-mount a host path into the container
   254             + `host_path:container_path:ro` to make the bind-mount read-only inside the container.
   255      -   **Links** - A list of links for the container. Each link entry should be
   256            in the form of `container_name:alias`.
   257      -   **LxcConf** - LXC specific configurations. These configurations only
   258            work when using the `lxc` execution driver.
   259      -   **PortBindings** - A map of exposed container ports and the host port they
   260            should map to. A JSON object in the form
   261            `{ <port>/<protocol>: [{ "HostPort": "<port>" }] }`
   262            Take note that `port` is specified as a string and not an integer value.
   263      -   **PublishAllPorts** - Allocates a random host port for all of a container's
   264            exposed ports. Specified as a boolean value.
   265      -   **Privileged** - Gives the container full access to the host. Specified as
   266            a boolean value.
   267      -   **ReadonlyRootfs** - Mount the container's root filesystem as read only.
   268            Specified as a boolean value.
   269      -   **Dns** - A list of DNS servers for the container to use.
   270      -   **DnsSearch** - A list of DNS search domains
   271      -   **ExtraHosts** - A list of hostnames/IP mappings to add to the
   272          container's `/etc/hosts` file. Specified in the form `["hostname:IP"]`.
   273      -   **VolumesFrom** - A list of volumes to inherit from another container.
   274            Specified in the form `<container name>[:<ro|rw>]`
   275      -   **CapAdd** - A list of kernel capabilities to add to the container.
   276      -   **Capdrop** - A list of kernel capabilities to drop from the container.
   277      -   **RestartPolicy** – The behavior to apply when the container exits.  The
   278              value is an object with a `Name` property of either `"always"` to
   279              always restart or `"on-failure"` to restart only when the container
   280              exit code is non-zero.  If `on-failure` is used, `MaximumRetryCount`
   281              controls the number of times to retry before giving up.
   282              The default is not to restart. (optional)
   283              An ever increasing delay (double the previous delay, starting at 100mS)
   284              is added before each restart to prevent flooding the server.
   285      -   **NetworkMode** - Sets the networking mode for the container. Supported
   286            values are: `bridge`, `host`, and `container:<name|id>`
   287      -   **Devices** - A list of devices to add to the container specified as a JSON object in the
   288        form
   289            `{ "PathOnHost": "/dev/deviceName", "PathInContainer": "/dev/deviceName", "CgroupPermissions": "mrw"}`
   290      -   **Ulimits** - A list of ulimits to set in the container, specified as
   291            `{ "Name": <name>, "Soft": <soft limit>, "Hard": <hard limit> }`, for example:
   292            `Ulimits: { "Name": "nofile", "Soft": 1024, "Hard": 2048 }`
   293      -   **SecurityOpt**: A list of string values to customize labels for MLS
   294          systems, such as SELinux.
   295      -   **LogConfig** - Log configuration for the container, specified as a JSON object in the form
   296            `{ "Type": "<driver_name>", "Config": {"key1": "val1"}}`.
   297            Available types: `json-file`, `syslog`, `journald`, `gelf`, `none`.
   298            `json-file` logging driver.
   299      -   **CgroupParent** - Path to `cgroups` under which the container's `cgroup` is created. If the path is not absolute, the path is considered to be relative to the `cgroups` path of the init process. Cgroups are created if they do not already exist.
   300  
   301  Query Parameters:
   302  
   303  -   **name** – Assign the specified name to the container. Must
   304      match `/?[a-zA-Z0-9_-]+`.
   305  
   306  Status Codes:
   307  
   308  -   **201** – no error
   309  -   **404** – no such container
   310  -   **406** – impossible to attach (container not running)
   311  -   **500** – server error
   312  
   313  ### Inspect a container
   314  
   315  `GET /containers/(id)/json`
   316  
   317  Return low-level information on the container `id`
   318  
   319  
   320  **Example request**:
   321  
   322        GET /containers/4fa6e0f0c678/json HTTP/1.1
   323  
   324  **Example response**:
   325  
   326      HTTP/1.1 200 OK
   327      Content-Type: application/json
   328  
   329      {
   330  		"AppArmorProfile": "",
   331  		"Args": [
   332  			"-c",
   333  			"exit 9"
   334  		],
   335  		"Config": {
   336  			"AttachStderr": true,
   337  			"AttachStdin": false,
   338  			"AttachStdout": true,
   339  			"Cmd": [
   340  				"/bin/sh",
   341  				"-c",
   342  				"exit 9"
   343  			],
   344  			"Domainname": "",
   345  			"Entrypoint": null,
   346  			"Env": [
   347  				"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
   348  			],
   349  			"ExposedPorts": null,
   350  			"Hostname": "ba033ac44011",
   351  			"Image": "ubuntu",
   352  			"Labels": {
   353  				"com.example.vendor": "Acme",
   354  				"com.example.license": "GPL",
   355  				"com.example.version": "1.0"
   356  			},
   357  			"MacAddress": "",
   358  			"NetworkDisabled": false,
   359  			"OnBuild": null,
   360  			"OpenStdin": false,
   361  			"StdinOnce": false,
   362  			"Tty": false,
   363  			"User": "",
   364  			"Volumes": null,
   365  			"WorkingDir": ""
   366  		},
   367  		"Created": "2015-01-06T15:47:31.485331387Z",
   368  		"Driver": "devicemapper",
   369  		"ExecDriver": "native-0.2",
   370  		"ExecIDs": null,
   371  		"HostConfig": {
   372  			"Binds": null,
   373  			"BlkioWeight": 0,
   374  			"CapAdd": null,
   375  			"CapDrop": null,
   376  			"ContainerIDFile": "",
   377  			"CpusetCpus": "",
   378  			"CpusetMems": "",
   379  			"CpuShares": 0,
   380  			"CpuPeriod": 100000,
   381  			"Devices": [],
   382  			"Dns": null,
   383  			"DnsSearch": null,
   384  			"ExtraHosts": null,
   385  			"IpcMode": "",
   386  			"Links": null,
   387  			"LxcConf": [],
   388  			"Memory": 0,
   389  			"MemorySwap": 0,
   390  			"OomKillDisable": false,
   391  			"NetworkMode": "bridge",
   392  			"PortBindings": {},
   393  			"Privileged": false,
   394  			"ReadonlyRootfs": false,
   395  			"PublishAllPorts": false,
   396  			"RestartPolicy": {
   397  				"MaximumRetryCount": 2,
   398  				"Name": "on-failure"
   399  			},
   400  			"LogConfig": {
   401  				"Config": null,
   402  				"Type": "json-file"
   403  			},
   404  			"SecurityOpt": null,
   405  			"VolumesFrom": null,
   406  			"Ulimits": [{}]
   407  		},
   408  		"HostnamePath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hostname",
   409  		"HostsPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/hosts",
   410  		"LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
   411  		"Id": "ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39",
   412  		"Image": "04c5d3b7b0656168630d3ba35d8889bd0e9caafcaeb3004d2bfbc47e7c5d35d2",
   413  		"MountLabel": "",
   414  		"Name": "/boring_euclid",
   415  		"NetworkSettings": {
   416  			"Bridge": "",
   417  			"Gateway": "",
   418  			"IPAddress": "",
   419  			"IPPrefixLen": 0,
   420  			"MacAddress": "",
   421  			"PortMapping": null,
   422  			"Ports": null
   423  		},
   424  		"Path": "/bin/sh",
   425  		"ProcessLabel": "",
   426  		"ResolvConfPath": "/var/lib/docker/containers/ba033ac4401106a3b513bc9d639eee123ad78ca3616b921167cd74b20e25ed39/resolv.conf",
   427  		"RestartCount": 1,
   428  		"State": {
   429  			"Error": "",
   430  			"ExitCode": 9,
   431  			"FinishedAt": "2015-01-06T15:47:32.080254511Z",
   432  			"OOMKilled": false,
   433  			"Paused": false,
   434  			"Pid": 0,
   435  			"Restarting": false,
   436  			"Running": false,
   437  			"StartedAt": "2015-01-06T15:47:32.072697474Z"
   438  		},
   439  		"Mounts": [
   440  			{
   441  				"Source": "/data",
   442  				"Destination": "/data",
   443  				"Mode": "ro,Z",
   444  				"RW": false
   445  			}
   446  		]
   447  	}
   448  
   449  Status Codes:
   450  
   451  -   **200** – no error
   452  -   **404** – no such container
   453  -   **500** – server error
   454  
   455  ### List processes running inside a container
   456  
   457  `GET /containers/(id)/top`
   458  
   459  List processes running inside the container `id`
   460  
   461  **Example request**:
   462  
   463      GET /containers/4fa6e0f0c678/top HTTP/1.1
   464  
   465  **Example response**:
   466  
   467      HTTP/1.1 200 OK
   468      Content-Type: application/json
   469  
   470      {
   471           "Titles": [
   472                   "USER",
   473                   "PID",
   474                   "%CPU",
   475                   "%MEM",
   476                   "VSZ",
   477                   "RSS",
   478                   "TTY",
   479                   "STAT",
   480                   "START",
   481                   "TIME",
   482                   "COMMAND"
   483                   ],
   484           "Processes": [
   485                   ["root","20147","0.0","0.1","18060","1864","pts/4","S","10:06","0:00","bash"],
   486                   ["root","20271","0.0","0.0","4312","352","pts/4","S+","10:07","0:00","sleep","10"]
   487           ]
   488      }
   489  
   490  Query Parameters:
   491  
   492  -   **ps_args** – ps arguments to use (e.g., aux)
   493  
   494  Status Codes:
   495  
   496  -   **200** – no error
   497  -   **404** – no such container
   498  -   **500** – server error
   499  
   500  ### Get container logs
   501  
   502  `GET /containers/(id)/logs`
   503  
   504  Get `stdout` and `stderr` logs from the container ``id``
   505  
   506  > **Note**:
   507  > This endpoint works only for containers with the `json-file` or `journald` logging drivers.
   508  
   509  **Example request**:
   510  
   511       GET /containers/4fa6e0f0c678/logs?stderr=1&stdout=1&timestamps=1&follow=1&tail=10&since=1428990821 HTTP/1.1
   512  
   513  **Example response**:
   514  
   515       HTTP/1.1 101 UPGRADED
   516       Content-Type: application/vnd.docker.raw-stream
   517       Connection: Upgrade
   518       Upgrade: tcp
   519  
   520       {{ STREAM }}
   521  
   522  Query Parameters:
   523  
   524  -   **follow** – 1/True/true or 0/False/false, return stream. Default `false`.
   525  -   **stdout** – 1/True/true or 0/False/false, show `stdout` log. Default `false`.
   526  -   **stderr** – 1/True/true or 0/False/false, show `stderr` log. Default `false`.
   527  -   **since** – UNIX timestamp (integer) to filter logs. Specifying a timestamp
   528      will only output log-entries since that timestamp. Default: 0 (unfiltered)
   529  -   **timestamps** – 1/True/true or 0/False/false, print timestamps for
   530          every log line. Default `false`.
   531  -   **tail** – Output specified number of lines at the end of logs: `all` or `<number>`. Default all.
   532  
   533  Status Codes:
   534  
   535  -   **101** – no error, hints proxy about hijacking
   536  -   **200** – no error, no upgrade header found
   537  -   **404** – no such container
   538  -   **500** – server error
   539  
   540  ### Inspect changes on a container's filesystem
   541  
   542  `GET /containers/(id)/changes`
   543  
   544  Inspect changes on container `id`'s filesystem
   545  
   546  **Example request**:
   547  
   548      GET /containers/4fa6e0f0c678/changes HTTP/1.1
   549  
   550  **Example response**:
   551  
   552      HTTP/1.1 200 OK
   553      Content-Type: application/json
   554  
   555      [
   556           {
   557                   "Path": "/dev",
   558                   "Kind": 0
   559           },
   560           {
   561                   "Path": "/dev/kmsg",
   562                   "Kind": 1
   563           },
   564           {
   565                   "Path": "/test",
   566                   "Kind": 1
   567           }
   568      ]
   569  
   570  Values for `Kind`:
   571  
   572  - `0`: Modify
   573  - `1`: Add
   574  - `2`: Delete
   575  
   576  Status Codes:
   577  
   578  -   **200** – no error
   579  -   **404** – no such container
   580  -   **500** – server error
   581  
   582  ### Export a container
   583  
   584  `GET /containers/(id)/export`
   585  
   586  Export the contents of container `id`
   587  
   588  **Example request**:
   589  
   590      GET /containers/4fa6e0f0c678/export HTTP/1.1
   591  
   592  **Example response**:
   593  
   594      HTTP/1.1 200 OK
   595      Content-Type: application/octet-stream
   596  
   597      {{ TAR STREAM }}
   598  
   599  Status Codes:
   600  
   601  -   **200** – no error
   602  -   **404** – no such container
   603  -   **500** – server error
   604  
   605  ### Get container stats based on resource usage
   606  
   607  `GET /containers/(id)/stats`
   608  
   609  This endpoint returns a live stream of a container's resource usage statistics.
   610  
   611  > **Note**: this functionality currently only works when using the *libcontainer* exec-driver.
   612  
   613  **Example request**:
   614  
   615      GET /containers/redis1/stats HTTP/1.1
   616  
   617  **Example response**:
   618  
   619        HTTP/1.1 200 OK
   620        Content-Type: application/json
   621  
   622        {
   623           "read" : "2015-01-08T22:57:31.547920715Z",
   624           "network" : {
   625              "rx_dropped" : 0,
   626              "rx_bytes" : 648,
   627              "rx_errors" : 0,
   628              "tx_packets" : 8,
   629              "tx_dropped" : 0,
   630              "rx_packets" : 8,
   631              "tx_errors" : 0,
   632              "tx_bytes" : 648
   633           },
   634           "memory_stats" : {
   635              "stats" : {
   636                 "total_pgmajfault" : 0,
   637                 "cache" : 0,
   638                 "mapped_file" : 0,
   639                 "total_inactive_file" : 0,
   640                 "pgpgout" : 414,
   641                 "rss" : 6537216,
   642                 "total_mapped_file" : 0,
   643                 "writeback" : 0,
   644                 "unevictable" : 0,
   645                 "pgpgin" : 477,
   646                 "total_unevictable" : 0,
   647                 "pgmajfault" : 0,
   648                 "total_rss" : 6537216,
   649                 "total_rss_huge" : 6291456,
   650                 "total_writeback" : 0,
   651                 "total_inactive_anon" : 0,
   652                 "rss_huge" : 6291456,
   653                 "hierarchical_memory_limit" : 67108864,
   654                 "total_pgfault" : 964,
   655                 "total_active_file" : 0,
   656                 "active_anon" : 6537216,
   657                 "total_active_anon" : 6537216,
   658                 "total_pgpgout" : 414,
   659                 "total_cache" : 0,
   660                 "inactive_anon" : 0,
   661                 "active_file" : 0,
   662                 "pgfault" : 964,
   663                 "inactive_file" : 0,
   664                 "total_pgpgin" : 477
   665              },
   666              "max_usage" : 6651904,
   667              "usage" : 6537216,
   668              "failcnt" : 0,
   669              "limit" : 67108864
   670           },
   671           "blkio_stats" : {},
   672           "cpu_stats" : {
   673              "cpu_usage" : {
   674                 "percpu_usage" : [
   675                    16970827,
   676                    1839451,
   677                    7107380,
   678                    10571290
   679                 ],
   680                 "usage_in_usermode" : 10000000,
   681                 "total_usage" : 36488948,
   682                 "usage_in_kernelmode" : 20000000
   683              },
   684              "system_cpu_usage" : 20091722000000000,
   685              "throttling_data" : {}
   686           }
   687        }
   688  
   689  Query Parameters:
   690  
   691  -   **stream** – 1/True/true or 0/False/false, pull stats once then disconnect. Default `true`.
   692  
   693  Status Codes:
   694  
   695  -   **200** – no error
   696  -   **404** – no such container
   697  -   **500** – server error
   698  
   699  ### Resize a container TTY
   700  
   701  `POST /containers/(id)/resize?h=<height>&w=<width>`
   702  
   703  Resize the TTY for container with  `id`. You must restart the container for the resize to take effect.
   704  
   705  **Example request**:
   706  
   707        POST /containers/4fa6e0f0c678/resize?h=40&w=80 HTTP/1.1
   708  
   709  **Example response**:
   710  
   711        HTTP/1.1 200 OK
   712        Content-Length: 0
   713        Content-Type: text/plain; charset=utf-8
   714  
   715  Status Codes:
   716  
   717  -   **200** – no error
   718  -   **404** – No such container
   719  -   **500** – Cannot resize container
   720  
   721  ### Start a container
   722  
   723  `POST /containers/(id)/start`
   724  
   725  Start the container `id`
   726  
   727  > **Note**:
   728  > For backwards compatibility, this endpoint accepts a `HostConfig` as JSON-encoded request body.
   729  > See [create a container](#create-a-container) for details.
   730  
   731  **Example request**:
   732  
   733      POST /containers/(id)/start HTTP/1.1
   734  
   735  **Example response**:
   736  
   737      HTTP/1.1 204 No Content
   738  
   739  Status Codes:
   740  
   741  -   **204** – no error
   742  -   **304** – container already started
   743  -   **404** – no such container
   744  -   **500** – server error
   745  
   746  ### Stop a container
   747  
   748  `POST /containers/(id)/stop`
   749  
   750  Stop the container `id`
   751  
   752  **Example request**:
   753  
   754      POST /containers/e90e34656806/stop?t=5 HTTP/1.1
   755  
   756  **Example response**:
   757  
   758      HTTP/1.1 204 No Content
   759  
   760  Query Parameters:
   761  
   762  -   **t** – number of seconds to wait before killing the container
   763  
   764  Status Codes:
   765  
   766  -   **204** – no error
   767  -   **304** – container already stopped
   768  -   **404** – no such container
   769  -   **500** – server error
   770  
   771  ### Restart a container
   772  
   773  `POST /containers/(id)/restart`
   774  
   775  Restart the container `id`
   776  
   777  **Example request**:
   778  
   779      POST /containers/e90e34656806/restart?t=5 HTTP/1.1
   780  
   781  **Example response**:
   782  
   783      HTTP/1.1 204 No Content
   784  
   785  Query Parameters:
   786  
   787  -   **t** – number of seconds to wait before killing the container
   788  
   789  Status Codes:
   790  
   791  -   **204** – no error
   792  -   **404** – no such container
   793  -   **500** – server error
   794  
   795  ### Kill a container
   796  
   797  `POST /containers/(id)/kill`
   798  
   799  Kill the container `id`
   800  
   801  **Example request**:
   802  
   803      POST /containers/e90e34656806/kill HTTP/1.1
   804  
   805  **Example response**:
   806  
   807      HTTP/1.1 204 No Content
   808  
   809  Query Parameters
   810  
   811  -   **signal** - Signal to send to the container: integer or string like `SIGINT`.
   812          When not set, `SIGKILL` is assumed and the call waits for the container to exit.
   813  
   814  Status Codes:
   815  
   816  -   **204** – no error
   817  -   **404** – no such container
   818  -   **500** – server error
   819  
   820  ### Rename a container
   821  
   822  `POST /containers/(id)/rename`
   823  
   824  Rename the container `id` to a `new_name`
   825  
   826  **Example request**:
   827  
   828      POST /containers/e90e34656806/rename?name=new_name HTTP/1.1
   829  
   830  **Example response**:
   831  
   832      HTTP/1.1 204 No Content
   833  
   834  Query Parameters:
   835  
   836  -   **name** – new name for the container
   837  
   838  Status Codes:
   839  
   840  -   **204** – no error
   841  -   **404** – no such container
   842  -   **409** - conflict name already assigned
   843  -   **500** – server error
   844  
   845  ### Pause a container
   846  
   847  `POST /containers/(id)/pause`
   848  
   849  Pause the container `id`
   850  
   851  **Example request**:
   852  
   853      POST /containers/e90e34656806/pause HTTP/1.1
   854  
   855  **Example response**:
   856  
   857      HTTP/1.1 204 No Content
   858  
   859  Status Codes:
   860  
   861  -   **204** – no error
   862  -   **404** – no such container
   863  -   **500** – server error
   864  
   865  ### Unpause a container
   866  
   867  `POST /containers/(id)/unpause`
   868  
   869  Unpause the container `id`
   870  
   871  **Example request**:
   872  
   873      POST /containers/e90e34656806/unpause HTTP/1.1
   874  
   875  **Example response**:
   876  
   877      HTTP/1.1 204 No Content
   878  
   879  Status Codes:
   880  
   881  -   **204** – no error
   882  -   **404** – no such container
   883  -   **500** – server error
   884  
   885  ### Attach to a container
   886  
   887  `POST /containers/(id)/attach`
   888  
   889  Attach to the container `id`
   890  
   891  **Example request**:
   892  
   893      POST /containers/16253994b7c4/attach?logs=1&stream=0&stdout=1 HTTP/1.1
   894  
   895  **Example response**:
   896  
   897      HTTP/1.1 101 UPGRADED
   898      Content-Type: application/vnd.docker.raw-stream
   899      Connection: Upgrade
   900      Upgrade: tcp
   901  
   902      {{ STREAM }}
   903  
   904  Query Parameters:
   905  
   906  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
   907  -   **stream** – 1/True/true or 0/False/false, return stream.
   908          Default `false`.
   909  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
   910          to `stdin`. Default `false`.
   911  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
   912          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
   913  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
   914          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
   915  
   916  Status Codes:
   917  
   918  -   **101** – no error, hints proxy about hijacking
   919  -   **200** – no error, no upgrade header found
   920  -   **400** – bad parameter
   921  -   **404** – no such container
   922  -   **500** – server error
   923  
   924      **Stream details**:
   925  
   926      When using the TTY setting is enabled in
   927      [`POST /containers/create`
   928      ](/reference/api/docker_remote_api_v1.9/#create-a-container "POST /containers/create"),
   929      the stream is the raw data from the process PTY and client's `stdin`.
   930      When the TTY is disabled, then the stream is multiplexed to separate
   931      `stdout` and `stderr`.
   932  
   933      The format is a **Header** and a **Payload** (frame).
   934  
   935      **HEADER**
   936  
   937      The header contains the information which the stream writes (`stdout` or
   938      `stderr`). It also contains the size of the associated frame encoded in the
   939      last four bytes (`uint32`).
   940  
   941      It is encoded on the first eight bytes like this:
   942  
   943          header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4}
   944  
   945      `STREAM_TYPE` can be:
   946  
   947  -   0: `stdin` (is written on `stdout`)
   948  -   1: `stdout`
   949  -   2: `stderr`
   950  
   951      `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of
   952      the `uint32` size encoded as big endian.
   953  
   954      **PAYLOAD**
   955  
   956      The payload is the raw stream.
   957  
   958      **IMPLEMENTATION**
   959  
   960      The simplest way to implement the Attach protocol is the following:
   961  
   962      1.  Read eight bytes.
   963      2.  Choose `stdout` or `stderr` depending on the first byte.
   964      3.  Extract the frame size from the last four bytes.
   965      4.  Read the extracted size and output it on the correct output.
   966      5.  Goto 1.
   967  
   968  ### Attach to a container (websocket)
   969  
   970  `GET /containers/(id)/attach/ws`
   971  
   972  Attach to the container `id` via websocket
   973  
   974  Implements websocket protocol handshake according to [RFC 6455](http://tools.ietf.org/html/rfc6455)
   975  
   976  **Example request**
   977  
   978      GET /containers/e90e34656806/attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1 HTTP/1.1
   979  
   980  **Example response**
   981  
   982      {{ STREAM }}
   983  
   984  Query Parameters:
   985  
   986  -   **logs** – 1/True/true or 0/False/false, return logs. Default `false`.
   987  -   **stream** – 1/True/true or 0/False/false, return stream.
   988          Default `false`.
   989  -   **stdin** – 1/True/true or 0/False/false, if `stream=true`, attach
   990          to `stdin`. Default `false`.
   991  -   **stdout** – 1/True/true or 0/False/false, if `logs=true`, return
   992          `stdout` log, if `stream=true`, attach to `stdout`. Default `false`.
   993  -   **stderr** – 1/True/true or 0/False/false, if `logs=true`, return
   994          `stderr` log, if `stream=true`, attach to `stderr`. Default `false`.
   995  
   996  Status Codes:
   997  
   998  -   **200** – no error
   999  -   **400** – bad parameter
  1000  -   **404** – no such container
  1001  -   **500** – server error
  1002  
  1003  ### Wait a container
  1004  
  1005  `POST /containers/(id)/wait`
  1006  
  1007  Block until container `id` stops, then returns the exit code
  1008  
  1009  **Example request**:
  1010  
  1011      POST /containers/16253994b7c4/wait HTTP/1.1
  1012  
  1013  **Example response**:
  1014  
  1015      HTTP/1.1 200 OK
  1016      Content-Type: application/json
  1017  
  1018      {"StatusCode": 0}
  1019  
  1020  Status Codes:
  1021  
  1022  -   **200** – no error
  1023  -   **404** – no such container
  1024  -   **500** – server error
  1025  
  1026  ### Remove a container
  1027  
  1028  `DELETE /containers/(id)`
  1029  
  1030  Remove the container `id` from the filesystem
  1031  
  1032  **Example request**:
  1033  
  1034      DELETE /containers/16253994b7c4?v=1 HTTP/1.1
  1035  
  1036  **Example response**:
  1037  
  1038      HTTP/1.1 204 No Content
  1039  
  1040  Query Parameters:
  1041  
  1042  -   **v** – 1/True/true or 0/False/false, Remove the volumes
  1043          associated to the container. Default `false`.
  1044  -   **force** - 1/True/true or 0/False/false, Kill then remove the container.
  1045          Default `false`.
  1046  
  1047  Status Codes:
  1048  
  1049  -   **204** – no error
  1050  -   **400** – bad parameter
  1051  -   **404** – no such container
  1052  -   **500** – server error
  1053  
  1054  ### Copy files or folders from a container
  1055  
  1056  `POST /containers/(id)/copy`
  1057  
  1058  Copy files or folders of container `id`
  1059  
  1060  **Deprecated** in favor of the `archive` endpoint below.
  1061  
  1062  **Example request**:
  1063  
  1064      POST /containers/4fa6e0f0c678/copy HTTP/1.1
  1065      Content-Type: application/json
  1066  
  1067      {
  1068           "Resource": "test.txt"
  1069      }
  1070  
  1071  **Example response**:
  1072  
  1073      HTTP/1.1 200 OK
  1074      Content-Type: application/x-tar
  1075  
  1076      {{ TAR STREAM }}
  1077  
  1078  Status Codes:
  1079  
  1080  -   **200** – no error
  1081  -   **404** – no such container
  1082  -   **500** – server error
  1083  
  1084  ### Retrieving information about files and folders in a container
  1085  
  1086  `HEAD /containers/(id)/archive`
  1087  
  1088  See the description of the `X-Docker-Container-Path-Stat` header in the
  1089  following section.
  1090  
  1091  ### Get an archive of a filesystem resource in a container
  1092  
  1093  `GET /containers/(id)/archive`
  1094  
  1095  Get an tar archive of a resource in the filesystem of container `id`.
  1096  
  1097  Query Parameters:
  1098  
  1099  - **path** - resource in the container's filesystem to archive. Required.
  1100  
  1101      If not an absolute path, it is relative to the container's root directory.
  1102      The resource specified by **path** must exist. To assert that the resource
  1103      is expected to be a directory, **path** should end in `/` or  `/.`
  1104      (assuming a path separator of `/`). If **path** ends in `/.` then this
  1105      indicates that only the contents of the **path** directory should be
  1106      copied. A symlink is always resolved to its target.
  1107  
  1108      **Note**: It is not possible to copy certain system files such as resources
  1109      under `/proc`, `/sys`, `/dev`, and mounts created by the user in the
  1110      container.
  1111  
  1112  **Example request**:
  1113  
  1114          GET /containers/8cce319429b2/archive?path=/root HTTP/1.1
  1115  
  1116  **Example response**:
  1117  
  1118          HTTP/1.1 200 OK
  1119          Content-Type: application/x-tar
  1120          X-Docker-Container-Path-Stat: eyJuYW1lIjoicm9vdCIsInNpemUiOjQwOTYsIm1vZGUiOjIxNDc0ODQwOTYsIm10aW1lIjoiMjAxNC0wMi0yN1QyMDo1MToyM1oiLCJsaW5rVGFyZ2V0IjoiIn0=
  1121  
  1122          {{ TAR STREAM }}
  1123  
  1124  On success, a response header `X-Docker-Container-Path-Stat` will be set to a
  1125  base64-encoded JSON object containing some filesystem header information about
  1126  the archived resource. The above example value would decode to the following
  1127  JSON object (whitespace added for readability):
  1128  
  1129          {
  1130              "name": "root",
  1131              "size": 4096,
  1132              "mode": 2147484096,
  1133              "mtime": "2014-02-27T20:51:23Z",
  1134              "linkTarget": ""
  1135          }
  1136  
  1137  A `HEAD` request can also be made to this endpoint if only this information is
  1138  desired.
  1139  
  1140  Status Codes:
  1141  
  1142  - **200** - success, returns archive of copied resource
  1143  - **400** - client error, bad parameter, details in JSON response body, one of:
  1144      - must specify path parameter (**path** cannot be empty)
  1145      - not a directory (**path** was asserted to be a directory but exists as a
  1146        file)
  1147  - **404** - client error, resource not found, one of:
  1148      – no such container (container `id` does not exist)
  1149      - no such file or directory (**path** does not exist)
  1150  - **500** - server error
  1151  
  1152  ### Extract an archive of files or folders to a directory in a container
  1153  
  1154  `PUT /containers/(id)/archive`
  1155  
  1156  Upload a tar archive to be extracted to a path in the filesystem of container
  1157  `id`.
  1158  
  1159  Query Parameters:
  1160  
  1161  - **path** - path to a directory in the container
  1162      to extract the archive's contents into. Required.
  1163  
  1164      If not an absolute path, it is relative to the container's root directory.
  1165      The **path** resource must exist.
  1166  - **noOverwriteDirNonDir** - If "1", "true", or "True" then it will be an error
  1167      if unpacking the given content would cause an existing directory to be
  1168      replaced with a non-directory and vice versa.
  1169  
  1170  **Example request**:
  1171  
  1172          PUT /containers/8cce319429b2/archive?path=/vol1 HTTP/1.1
  1173          Content-Type: application/x-tar
  1174  
  1175          {{ TAR STREAM }}
  1176  
  1177  **Example response**:
  1178  
  1179          HTTP/1.1 200 OK
  1180  
  1181  Status Codes:
  1182  
  1183  - **200** – the content was extracted successfully
  1184  - **400** - client error, bad parameter, details in JSON response body, one of:
  1185      - must specify path parameter (**path** cannot be empty)
  1186      - not a directory (**path** should be a directory but exists as a file)
  1187      - unable to overwrite existing directory with non-directory
  1188        (if **noOverwriteDirNonDir**)
  1189      - unable to overwrite existing non-directory with directory
  1190        (if **noOverwriteDirNonDir**)
  1191  - **403** - client error, permission denied, the volume
  1192      or container rootfs is marked as read-only.
  1193  - **404** - client error, resource not found, one of:
  1194      – no such container (container `id` does not exist)
  1195      - no such file or directory (**path** resource does not exist)
  1196  - **500** – server error
  1197  
  1198  ## 2.2 Images
  1199  
  1200  ### List Images
  1201  
  1202  `GET /images/json`
  1203  
  1204  **Example request**:
  1205  
  1206      GET /images/json?all=0 HTTP/1.1
  1207  
  1208  **Example response**:
  1209  
  1210      HTTP/1.1 200 OK
  1211      Content-Type: application/json
  1212  
  1213      [
  1214        {
  1215           "RepoTags": [
  1216             "ubuntu:12.04",
  1217             "ubuntu:precise",
  1218             "ubuntu:latest"
  1219           ],
  1220           "Id": "8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c",
  1221           "Created": 1365714795,
  1222           "Size": 131506275,
  1223           "VirtualSize": 131506275
  1224        },
  1225        {
  1226           "RepoTags": [
  1227             "ubuntu:12.10",
  1228             "ubuntu:quantal"
  1229           ],
  1230           "ParentId": "27cf784147099545",
  1231           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1232           "Created": 1364102658,
  1233           "Size": 24653,
  1234           "VirtualSize": 180116135
  1235        }
  1236      ]
  1237  
  1238  **Example request, with digest information**:
  1239  
  1240      GET /images/json?digests=1 HTTP/1.1
  1241  
  1242  **Example response, with digest information**:
  1243  
  1244      HTTP/1.1 200 OK
  1245      Content-Type: application/json
  1246  
  1247      [
  1248        {
  1249          "Created": 1420064636,
  1250          "Id": "4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125",
  1251          "ParentId": "ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2",
  1252          "RepoDigests": [
  1253            "localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf"
  1254          ],
  1255          "RepoTags": [
  1256            "localhost:5000/test/busybox:latest",
  1257            "playdate:latest"
  1258          ],
  1259          "Size": 0,
  1260          "VirtualSize": 2429728
  1261        }
  1262      ]
  1263  
  1264  The response shows a single image `Id` associated with two repositories
  1265  (`RepoTags`): `localhost:5000/test/busybox`: and `playdate`. A caller can use
  1266  either of the `RepoTags` values `localhost:5000/test/busybox:latest` or
  1267  `playdate:latest` to reference the image.
  1268  
  1269  You can also use `RepoDigests` values to reference an image. In this response,
  1270  the array has only one reference and that is to the
  1271  `localhost:5000/test/busybox` repository; the `playdate` repository has no
  1272  digest. You can reference this digest using the value:
  1273  `localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d...`
  1274  
  1275  See the `docker run` and `docker build` commands for examples of digest and tag
  1276  references on the command line.
  1277  
  1278  Query Parameters:
  1279  
  1280  -   **all** – 1/True/true or 0/False/false, default false
  1281  -   **filters** – a JSON encoded value of the filters (a map[string][]string) to process on the images list. Available filters:
  1282    -   `dangling=true`
  1283    -   `label=key` or `label="key=value"` of an image label
  1284  -   **filter** - only return images with the specified name
  1285  
  1286  ### Build image from a Dockerfile
  1287  
  1288  `POST /build`
  1289  
  1290  Build an image from a Dockerfile
  1291  
  1292  **Example request**:
  1293  
  1294      POST /build HTTP/1.1
  1295  
  1296      {{ TAR STREAM }}
  1297  
  1298  **Example response**:
  1299  
  1300      HTTP/1.1 200 OK
  1301      Content-Type: application/json
  1302  
  1303      {"stream": "Step 1..."}
  1304      {"stream": "..."}
  1305      {"error": "Error...", "errorDetail": {"code": 123, "message": "Error..."}}
  1306  
  1307  The input stream must be a `tar` archive compressed with one of the
  1308  following algorithms: `identity` (no compression), `gzip`, `bzip2`, `xz`.
  1309  
  1310  The archive must include a build instructions file, typically called
  1311  `Dockerfile` at the archive's root. The `dockerfile` parameter may be
  1312  used to specify a different build instructions file. To do this, its value must be
  1313  the path to the alternate build instructions file to use.
  1314  
  1315  The archive may include any number of other files,
  1316  which are accessible in the build context (See the [*ADD build
  1317  command*](/reference/builder/#dockerbuilder)).
  1318  
  1319  The build is canceled if the client drops the connection by quitting
  1320  or being killed.
  1321  
  1322  Query Parameters:
  1323  
  1324  -   **dockerfile** - Path within the build context to the Dockerfile. This is 
  1325          ignored if `remote` is specified and points to an individual filename.
  1326  -   **t** – A repository name (and optionally a tag) to apply to
  1327          the resulting image in case of success.
  1328  -   **remote** – A Git repository URI or HTTP/HTTPS URI build source. If the 
  1329          URI specifies a filename, the file's contents are placed into a file 
  1330  		called `Dockerfile`.
  1331  -   **q** – Suppress verbose build output.
  1332  -   **nocache** – Do not use the cache when building the image.
  1333  -   **pull** - Attempt to pull the image even if an older image exists locally.
  1334  -   **rm** - Remove intermediate containers after a successful build (default behavior).
  1335  -   **forcerm** - Always remove intermediate containers (includes `rm`).
  1336  -   **memory** - Set memory limit for build.
  1337  -   **memswap** - Total memory (memory + swap), `-1` to disable swap.
  1338  -   **cpushares** - CPU shares (relative weight).
  1339  -   **cpusetcpus** - CPUs in which to allow execution (e.g., `0-3`, `0,1`).
  1340  
  1341      Request Headers:
  1342  
  1343  -   **Content-type** – Set to `"application/tar"`.
  1344  -   **X-Registry-Config** – A base64-url-safe-encoded Registry Auth Config JSON
  1345          object with the following structure:
  1346  
  1347              {
  1348                  "docker.example.com": {
  1349                      "username": "janedoe",
  1350                      "password": "hunter2"
  1351                  },
  1352                  "https://index.docker.io/v1/": {
  1353                      "username": "mobydock",
  1354                      "password": "conta1n3rize14"
  1355                  }
  1356              }
  1357  
  1358          This object maps the hostname of a registry to an object containing the
  1359          "username" and "password" for that registry. Multiple registries may
  1360          be specified as the build may be based on an image requiring
  1361          authentication to pull from any arbitrary registry. Only the registry
  1362          domain name (and port if not the default "443") are required. However
  1363          (for legacy reasons) the "official" Docker, Inc. hosted registry must
  1364          be specified with both a "https://" prefix and a "/v1/" suffix even
  1365          though Docker will prefer to use the v2 registry API.
  1366  
  1367  Status Codes:
  1368  
  1369  -   **200** – no error
  1370  -   **500** – server error
  1371  
  1372  ### Create an image
  1373  
  1374  `POST /images/create`
  1375  
  1376  Create an image either by pulling it from the registry or by importing it
  1377  
  1378  **Example request**:
  1379  
  1380      POST /images/create?fromImage=ubuntu HTTP/1.1
  1381  
  1382  **Example response**:
  1383  
  1384      HTTP/1.1 200 OK
  1385      Content-Type: application/json
  1386  
  1387      {"status": "Pulling..."}
  1388      {"status": "Pulling", "progress": "1 B/ 100 B", "progressDetail": {"current": 1, "total": 100}}
  1389      {"error": "Invalid..."}
  1390      ...
  1391  
  1392  When using this endpoint to pull an image from the registry, the
  1393  `X-Registry-Auth` header can be used to include
  1394  a base64-encoded AuthConfig object.
  1395  
  1396  Query Parameters:
  1397  
  1398  -   **fromImage** – Name of the image to pull.
  1399  -   **fromSrc** – Source to import.  The value may be a URL from which the image
  1400          can be retrieved or `-` to read the image from the request body.
  1401  -   **repo** – Repository name.
  1402  -   **tag** – Tag.
  1403  -   **registry** – The registry to pull from.
  1404  
  1405      Request Headers:
  1406  
  1407  -   **X-Registry-Auth** – base64-encoded AuthConfig object
  1408  
  1409  Status Codes:
  1410  
  1411  -   **200** – no error
  1412  -   **500** – server error
  1413  
  1414  
  1415  
  1416  ### Inspect an image
  1417  
  1418  `GET /images/(name)/json`
  1419  
  1420  Return low-level information on the image `name`
  1421  
  1422  **Example request**:
  1423  
  1424      GET /images/ubuntu/json HTTP/1.1
  1425  
  1426  **Example response**:
  1427  
  1428      HTTP/1.1 200 OK
  1429      Content-Type: application/json
  1430  
  1431      {
  1432           "Created": "2013-03-23T22:24:18.818426-07:00",
  1433           "Container": "3d67245a8d72ecf13f33dffac9f79dcdf70f75acb84d308770391510e0c23ad0",
  1434           "ContainerConfig":
  1435                   {
  1436                           "Hostname": "",
  1437                           "User": "",
  1438                           "AttachStdin": false,
  1439                           "AttachStdout": false,
  1440                           "AttachStderr": false,
  1441                           "Tty": true,
  1442                           "OpenStdin": true,
  1443                           "StdinOnce": false,
  1444                           "Env": null,
  1445                           "Cmd": ["/bin/bash"],
  1446                           "Dns": null,
  1447                           "Image": "ubuntu",
  1448                           "Labels": {
  1449                               "com.example.vendor": "Acme",
  1450                               "com.example.license": "GPL",
  1451                               "com.example.version": "1.0"
  1452                           },
  1453                           "Volumes": null,
  1454                           "VolumesFrom": "",
  1455                           "WorkingDir": ""
  1456                   },
  1457           "Id": "b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc",
  1458           "Parent": "27cf784147099545",
  1459           "Size": 6824592
  1460      }
  1461  
  1462  Status Codes:
  1463  
  1464  -   **200** – no error
  1465  -   **404** – no such image
  1466  -   **500** – server error
  1467  
  1468  ### Get the history of an image
  1469  
  1470  `GET /images/(name)/history`
  1471  
  1472  Return the history of the image `name`
  1473  
  1474  **Example request**:
  1475  
  1476      GET /images/ubuntu/history HTTP/1.1
  1477  
  1478  **Example response**:
  1479  
  1480      HTTP/1.1 200 OK
  1481      Content-Type: application/json
  1482  
  1483      [
  1484          {
  1485              "Id": "3db9c44f45209632d6050b35958829c3a2aa256d81b9a7be45b362ff85c54710",
  1486              "Created": 1398108230,
  1487              "CreatedBy": "/bin/sh -c #(nop) ADD file:eb15dbd63394e063b805a3c32ca7bf0266ef64676d5a6fab4801f2e81e2a5148 in /",
  1488              "Tags": [
  1489                  "ubuntu:lucid",
  1490                  "ubuntu:10.04"
  1491              ],
  1492              "Size": 182964289,
  1493              "Comment": ""
  1494          },
  1495          {
  1496              "Id": "6cfa4d1f33fb861d4d114f43b25abd0ac737509268065cdfd69d544a59c85ab8",
  1497              "Created": 1398108222,
  1498              "CreatedBy": "/bin/sh -c #(nop) MAINTAINER Tianon Gravi <admwiggin@gmail.com> - mkimage-debootstrap.sh -i iproute,iputils-ping,ubuntu-minimal -t lucid.tar.xz lucid http://archive.ubuntu.com/ubuntu/",
  1499              "Tags": null,
  1500              "Size": 0,
  1501              "Comment": ""
  1502          },
  1503          {
  1504              "Id": "511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158",
  1505              "Created": 1371157430,
  1506              "CreatedBy": "",
  1507              "Tags": [
  1508                  "scratch12:latest",
  1509                  "scratch:latest"
  1510              ],
  1511              "Size": 0,
  1512              "Comment": "Imported from -"
  1513          }
  1514      ]
  1515  
  1516  Status Codes:
  1517  
  1518  -   **200** – no error
  1519  -   **404** – no such image
  1520  -   **500** – server error
  1521  
  1522  ### Push an image on the registry
  1523  
  1524  `POST /images/(name)/push`
  1525  
  1526  Push the image `name` on the registry
  1527  
  1528  **Example request**:
  1529  
  1530      POST /images/test/push HTTP/1.1
  1531  
  1532  **Example response**:
  1533  
  1534      HTTP/1.1 200 OK
  1535      Content-Type: application/json
  1536  
  1537      {"status": "Pushing..."}
  1538      {"status": "Pushing", "progress": "1/? (n/a)", "progressDetail": {"current": 1}}}
  1539      {"error": "Invalid..."}
  1540      ...
  1541  
  1542  If you wish to push an image on to a private registry, that image must already have a tag
  1543  into a repository which references that registry `hostname` and `port`.  This repository name should
  1544  then be used in the URL. This duplicates the command line's flow.
  1545  
  1546  **Example request**:
  1547  
  1548      POST /images/registry.acme.com:5000/test/push HTTP/1.1
  1549  
  1550  
  1551  Query Parameters:
  1552  
  1553  -   **tag** – The tag to associate with the image on the registry. This is optional.
  1554  
  1555  Request Headers:
  1556  
  1557  -   **X-Registry-Auth** – Include a base64-encoded AuthConfig.
  1558          object.
  1559  
  1560  Status Codes:
  1561  
  1562  -   **200** – no error
  1563  -   **404** – no such image
  1564  -   **500** – server error
  1565  
  1566  ### Tag an image into a repository
  1567  
  1568  `POST /images/(name)/tag`
  1569  
  1570  Tag the image `name` into a repository
  1571  
  1572  **Example request**:
  1573  
  1574      POST /images/test/tag?repo=myrepo&force=0&tag=v42 HTTP/1.1
  1575  
  1576  **Example response**:
  1577  
  1578      HTTP/1.1 201 OK
  1579  
  1580  Query Parameters:
  1581  
  1582  -   **repo** – The repository to tag in
  1583  -   **force** – 1/True/true or 0/False/false, default false
  1584  -   **tag** - The new tag name
  1585  
  1586  Status Codes:
  1587  
  1588  -   **201** – no error
  1589  -   **400** – bad parameter
  1590  -   **404** – no such image
  1591  -   **409** – conflict
  1592  -   **500** – server error
  1593  
  1594  ### Remove an image
  1595  
  1596  `DELETE /images/(name)`
  1597  
  1598  Remove the image `name` from the filesystem
  1599  
  1600  **Example request**:
  1601  
  1602      DELETE /images/test HTTP/1.1
  1603  
  1604  **Example response**:
  1605  
  1606      HTTP/1.1 200 OK
  1607      Content-type: application/json
  1608  
  1609      [
  1610       {"Untagged": "3e2f21a89f"},
  1611       {"Deleted": "3e2f21a89f"},
  1612       {"Deleted": "53b4f83ac9"}
  1613      ]
  1614  
  1615  Query Parameters:
  1616  
  1617  -   **force** – 1/True/true or 0/False/false, default false
  1618  -   **noprune** – 1/True/true or 0/False/false, default false
  1619  
  1620  Status Codes:
  1621  
  1622  -   **200** – no error
  1623  -   **404** – no such image
  1624  -   **409** – conflict
  1625  -   **500** – server error
  1626  
  1627  ### Search images
  1628  
  1629  `GET /images/search`
  1630  
  1631  Search for an image on [Docker Hub](https://hub.docker.com).
  1632  
  1633  > **Note**:
  1634  > The response keys have changed from API v1.6 to reflect the JSON
  1635  > sent by the registry server to the docker daemon's request.
  1636  
  1637  **Example request**:
  1638  
  1639      GET /images/search?term=sshd HTTP/1.1
  1640  
  1641  **Example response**:
  1642  
  1643      HTTP/1.1 200 OK
  1644      Content-Type: application/json
  1645  
  1646      [
  1647              {
  1648                  "description": "",
  1649                  "is_official": false,
  1650                  "is_automated": false,
  1651                  "name": "wma55/u1210sshd",
  1652                  "star_count": 0
  1653              },
  1654              {
  1655                  "description": "",
  1656                  "is_official": false,
  1657                  "is_automated": false,
  1658                  "name": "jdswinbank/sshd",
  1659                  "star_count": 0
  1660              },
  1661              {
  1662                  "description": "",
  1663                  "is_official": false,
  1664                  "is_automated": false,
  1665                  "name": "vgauthier/sshd",
  1666                  "star_count": 0
  1667              }
  1668      ...
  1669      ]
  1670  
  1671  Query Parameters:
  1672  
  1673  -   **term** – term to search
  1674  
  1675  Status Codes:
  1676  
  1677  -   **200** – no error
  1678  -   **500** – server error
  1679  
  1680  ## 2.3 Misc
  1681  
  1682  ### Check auth configuration
  1683  
  1684  `POST /auth`
  1685  
  1686  Get the default username and email
  1687  
  1688  **Example request**:
  1689  
  1690      POST /auth HTTP/1.1
  1691      Content-Type: application/json
  1692  
  1693      {
  1694           "username":" hannibal",
  1695           "password: "xxxx",
  1696           "email": "hannibal@a-team.com",
  1697           "serveraddress": "https://index.docker.io/v1/"
  1698      }
  1699  
  1700  **Example response**:
  1701  
  1702      HTTP/1.1 200 OK
  1703  
  1704  Status Codes:
  1705  
  1706  -   **200** – no error
  1707  -   **204** – no error
  1708  -   **500** – server error
  1709  
  1710  ### Display system-wide information
  1711  
  1712  `GET /info`
  1713  
  1714  Display system-wide information
  1715  
  1716  **Example request**:
  1717  
  1718      GET /info HTTP/1.1
  1719  
  1720  **Example response**:
  1721  
  1722      HTTP/1.1 200 OK
  1723      Content-Type: application/json
  1724  
  1725      {
  1726          "Containers": 11,
  1727          "CpuCfsPeriod": true,
  1728          "CpuCfsQuota": true,
  1729          "Debug": false,
  1730          "DockerRootDir": "/var/lib/docker",
  1731          "Driver": "btrfs",
  1732          "DriverStatus": [[""]],
  1733          "ExecutionDriver": "native-0.1",
  1734          "ExperimentalBuild": false,
  1735          "HttpProxy": "http://test:test@localhost:8080",
  1736          "HttpsProxy": "https://test:test@localhost:8080",
  1737          "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
  1738          "IPv4Forwarding": true,
  1739          "Images": 16,
  1740          "IndexServerAddress": "https://index.docker.io/v1/",
  1741          "InitPath": "/usr/bin/docker",
  1742          "InitSha1": "",
  1743          "KernelVersion": "3.12.0-1-amd64",
  1744          "Labels": [
  1745              "storage=ssd"
  1746          ],
  1747          "MemTotal": 2099236864,
  1748          "MemoryLimit": true,
  1749          "NCPU": 1,
  1750          "NEventsListener": 0,
  1751          "NFd": 11,
  1752          "NGoroutines": 21,
  1753          "Name": "prod-server-42",
  1754          "NoProxy": "9.81.1.160",
  1755          "OomKillDisable": true,
  1756          "OperatingSystem": "Boot2Docker",
  1757          "RegistryConfig": {
  1758              "IndexConfigs": {
  1759                  "docker.io": {
  1760                      "Mirrors": null,
  1761                      "Name": "docker.io",
  1762                      "Official": true,
  1763                      "Secure": true
  1764                  }
  1765              },
  1766              "InsecureRegistryCIDRs": [
  1767                  "127.0.0.0/8"
  1768              ]
  1769          },
  1770          "SwapLimit": false,
  1771          "SystemTime": "2015-03-10T11:11:23.730591467-07:00"
  1772      }
  1773  
  1774  Status Codes:
  1775  
  1776  -   **200** – no error
  1777  -   **500** – server error
  1778  
  1779  ### Show the docker version information
  1780  
  1781  `GET /version`
  1782  
  1783  Show the docker version information
  1784  
  1785  **Example request**:
  1786  
  1787      GET /version HTTP/1.1
  1788  
  1789  **Example response**:
  1790  
  1791      HTTP/1.1 200 OK
  1792      Content-Type: application/json
  1793  
  1794      {
  1795           "Version": "1.5.0",
  1796           "Os": "linux",
  1797           "KernelVersion": "3.18.5-tinycore64",
  1798           "GoVersion": "go1.4.1",
  1799           "GitCommit": "a8a31ef",
  1800           "Arch": "amd64",
  1801           "ApiVersion": "1.20",
  1802           "Experimental": false
  1803      }
  1804  
  1805  Status Codes:
  1806  
  1807  -   **200** – no error
  1808  -   **500** – server error
  1809  
  1810  ### Ping the docker server
  1811  
  1812  `GET /_ping`
  1813  
  1814  Ping the docker server
  1815  
  1816  **Example request**:
  1817  
  1818      GET /_ping HTTP/1.1
  1819  
  1820  **Example response**:
  1821  
  1822      HTTP/1.1 200 OK
  1823      Content-Type: text/plain
  1824  
  1825      OK
  1826  
  1827  Status Codes:
  1828  
  1829  -   **200** - no error
  1830  -   **500** - server error
  1831  
  1832  ### Create a new image from a container's changes
  1833  
  1834  `POST /commit`
  1835  
  1836  Create a new image from a container's changes
  1837  
  1838  **Example request**:
  1839  
  1840      POST /commit?container=44c004db4b17&comment=message&repo=myrepo HTTP/1.1
  1841      Content-Type: application/json
  1842  
  1843      {
  1844           "Hostname": "",
  1845           "Domainname": "",
  1846           "User": "",
  1847           "AttachStdin": false,
  1848           "AttachStdout": true,
  1849           "AttachStderr": true,
  1850           "Tty": false,
  1851           "OpenStdin": false,
  1852           "StdinOnce": false,
  1853           "Env": null,
  1854           "Cmd": [
  1855                   "date"
  1856           ],
  1857           "Mounts": [
  1858             {
  1859               "Source": "/data",
  1860               "Destination": "/data",
  1861               "Mode": "ro,Z",
  1862               "RW": false
  1863             }
  1864           ],
  1865           "Labels": {
  1866                   "key1": "value1",
  1867                   "key2": "value2"
  1868            },
  1869           "WorkingDir": "",
  1870           "NetworkDisabled": false,
  1871           "ExposedPorts": {
  1872                   "22/tcp": {}
  1873           }
  1874      }
  1875  
  1876  **Example response**:
  1877  
  1878      HTTP/1.1 201 Created
  1879      Content-Type: application/vnd.docker.raw-stream
  1880  
  1881      {"Id": "596069db4bf5"}
  1882  
  1883  Json Parameters:
  1884  
  1885  -  **config** - the container's configuration
  1886  
  1887  Query Parameters:
  1888  
  1889  -   **container** – source container
  1890  -   **repo** – repository
  1891  -   **tag** – tag
  1892  -   **comment** – commit message
  1893  -   **author** – author (e.g., "John Hannibal Smith
  1894      <[hannibal@a-team.com](mailto:hannibal%40a-team.com)>")
  1895  
  1896  Status Codes:
  1897  
  1898  -   **201** – no error
  1899  -   **404** – no such container
  1900  -   **500** – server error
  1901  
  1902  ### Monitor Docker's events
  1903  
  1904  `GET /events`
  1905  
  1906  Get container events from docker, either in real time via streaming, or via
  1907  polling (using since).
  1908  
  1909  Docker containers report the following events:
  1910  
  1911      attach, commit, copy, create, destroy, die, exec_create, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause
  1912  
  1913  and Docker images report:
  1914  
  1915      delete, import, pull, push, tag, untag
  1916  
  1917  **Example request**:
  1918  
  1919      GET /events?since=1374067924
  1920  
  1921  **Example response**:
  1922  
  1923      HTTP/1.1 200 OK
  1924      Content-Type: application/json
  1925  
  1926      {"status": "create", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1927      {"status": "start", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067924}
  1928      {"status": "stop", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067966}
  1929      {"status": "destroy", "id": "dfdf82bd3881","from": "ubuntu:latest", "time":1374067970}
  1930  
  1931  Query Parameters:
  1932  
  1933  -   **since** – Timestamp used for polling
  1934  -   **until** – Timestamp used for polling
  1935  -   **filters** – A json encoded value of the filters (a map[string][]string) to process on the event list. Available filters:
  1936    -   `event=<string>`; -- event to filter
  1937    -   `image=<string>`; -- image to filter
  1938    -   `container=<string>`; -- container to filter
  1939  
  1940  Status Codes:
  1941  
  1942  -   **200** – no error
  1943  -   **500** – server error
  1944  
  1945  ### Get a tarball containing all images in a repository
  1946  
  1947  `GET /images/(name)/get`
  1948  
  1949  Get a tarball containing all images and metadata for the repository specified
  1950  by `name`.
  1951  
  1952  If `name` is a specific name and tag (e.g. ubuntu:latest), then only that image
  1953  (and its parents) are returned. If `name` is an image ID, similarly only that
  1954  image (and its parents) are returned, but with the exclusion of the
  1955  'repositories' file in the tarball, as there were no image names referenced.
  1956  
  1957  See the [image tarball format](#image-tarball-format) for more details.
  1958  
  1959  **Example request**
  1960  
  1961      GET /images/ubuntu/get
  1962  
  1963  **Example response**:
  1964  
  1965      HTTP/1.1 200 OK
  1966      Content-Type: application/x-tar
  1967  
  1968      Binary data stream
  1969  
  1970  Status Codes:
  1971  
  1972  -   **200** – no error
  1973  -   **500** – server error
  1974  
  1975  ### Get a tarball containing all images.
  1976  
  1977  `GET /images/get`
  1978  
  1979  Get a tarball containing all images and metadata for one or more repositories.
  1980  
  1981  For each value of the `names` parameter: if it is a specific name and tag (e.g.
  1982  `ubuntu:latest`), then only that image (and its parents) are returned; if it is
  1983  an image ID, similarly only that image (and its parents) are returned and there
  1984  would be no names referenced in the 'repositories' file for this image ID.
  1985  
  1986  See the [image tarball format](#image-tarball-format) for more details.
  1987  
  1988  **Example request**
  1989  
  1990      GET /images/get?names=myname%2Fmyapp%3Alatest&names=busybox
  1991  
  1992  **Example response**:
  1993  
  1994      HTTP/1.1 200 OK
  1995      Content-Type: application/x-tar
  1996  
  1997      Binary data stream
  1998  
  1999  Status Codes:
  2000  
  2001  -   **200** – no error
  2002  -   **500** – server error
  2003  
  2004  ### Load a tarball with a set of images and tags into docker
  2005  
  2006  `POST /images/load`
  2007  
  2008  Load a set of images and tags into a Docker repository.
  2009  See the [image tarball format](#image-tarball-format) for more details.
  2010  
  2011  **Example request**
  2012  
  2013      POST /images/load
  2014  
  2015      Tarball in body
  2016  
  2017  **Example response**:
  2018  
  2019      HTTP/1.1 200 OK
  2020  
  2021  Status Codes:
  2022  
  2023  -   **200** – no error
  2024  -   **500** – server error
  2025  
  2026  ### Image tarball format
  2027  
  2028  An image tarball contains one directory per image layer (named using its long ID),
  2029  each containing these files:
  2030  
  2031  - `VERSION`: currently `1.0` - the file format version
  2032  - `json`: detailed layer information, similar to `docker inspect layer_id`
  2033  - `layer.tar`: A tarfile containing the filesystem changes in this layer
  2034  
  2035  The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories
  2036  for storing attribute changes and deletions.
  2037  
  2038  If the tarball defines a repository, the tarball should also include a `repositories` file at
  2039  the root that contains a list of repository and tag names mapped to layer IDs.
  2040  
  2041  ```
  2042  {"hello-world":
  2043      {"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"}
  2044  }
  2045  ```
  2046  
  2047  ### Exec Create
  2048  
  2049  `POST /containers/(id)/exec`
  2050  
  2051  Sets up an exec instance in a running container `id`
  2052  
  2053  **Example request**:
  2054  
  2055      POST /containers/e90e34656806/exec HTTP/1.1
  2056      Content-Type: application/json
  2057  
  2058        {
  2059         "AttachStdin": false,
  2060         "AttachStdout": true,
  2061         "AttachStderr": true,
  2062         "Tty": false,
  2063         "Cmd": [
  2064                       "date"
  2065               ]
  2066        }
  2067  
  2068  **Example response**:
  2069  
  2070      HTTP/1.1 201 OK
  2071      Content-Type: application/json
  2072  
  2073      {
  2074           "Id": "f90e34656806",
  2075           "Warnings":[]
  2076      }
  2077  
  2078  Json Parameters:
  2079  
  2080  -   **AttachStdin** - Boolean value, attaches to `stdin` of the `exec` command.
  2081  -   **AttachStdout** - Boolean value, attaches to `stdout` of the `exec` command.
  2082  -   **AttachStderr** - Boolean value, attaches to `stderr` of the `exec` command.
  2083  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2084  -   **Cmd** - Command to run specified as a string or an array of strings.
  2085  
  2086  
  2087  Status Codes:
  2088  
  2089  -   **201** – no error
  2090  -   **404** – no such container
  2091  
  2092  ### Exec Start
  2093  
  2094  `POST /exec/(id)/start`
  2095  
  2096  Starts a previously set up `exec` instance `id`. If `detach` is true, this API
  2097  returns after starting the `exec` command. Otherwise, this API sets up an
  2098  interactive session with the `exec` command.
  2099  
  2100  **Example request**:
  2101  
  2102      POST /exec/e90e34656806/start HTTP/1.1
  2103      Content-Type: application/json
  2104  
  2105      {
  2106       "Detach": false,
  2107       "Tty": false
  2108      }
  2109  
  2110  **Example response**:
  2111  
  2112      HTTP/1.1 201 OK
  2113      Content-Type: application/json
  2114  
  2115      {{ STREAM }}
  2116  
  2117  Json Parameters:
  2118  
  2119  -   **Detach** - Detach from the `exec` command.
  2120  -   **Tty** - Boolean value to allocate a pseudo-TTY.
  2121  
  2122  Status Codes:
  2123  
  2124  -   **201** – no error
  2125  -   **404** – no such exec instance
  2126  
  2127      **Stream details**:
  2128      Similar to the stream behavior of `POST /container/(id)/attach` API
  2129  
  2130  ### Exec Resize
  2131  
  2132  `POST /exec/(id)/resize`
  2133  
  2134  Resizes the `tty` session used by the `exec` command `id`.
  2135  This API is valid only if `tty` was specified as part of creating and starting the `exec` command.
  2136  
  2137  **Example request**:
  2138  
  2139      POST /exec/e90e34656806/resize HTTP/1.1
  2140      Content-Type: text/plain
  2141  
  2142  **Example response**:
  2143  
  2144      HTTP/1.1 201 OK
  2145      Content-Type: text/plain
  2146  
  2147  Query Parameters:
  2148  
  2149  -   **h** – height of `tty` session
  2150  -   **w** – width
  2151  
  2152  Status Codes:
  2153  
  2154  -   **201** – no error
  2155  -   **404** – no such exec instance
  2156  
  2157  ### Exec Inspect
  2158  
  2159  `GET /exec/(id)/json`
  2160  
  2161  Return low-level information about the `exec` command `id`.
  2162  
  2163  **Example request**:
  2164  
  2165      GET /exec/11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39/json HTTP/1.1
  2166  
  2167  **Example response**:
  2168  
  2169      HTTP/1.1 200 OK
  2170      Content-Type: plain/text
  2171  
  2172      {
  2173        "ID" : "11fb006128e8ceb3942e7c58d77750f24210e35f879dd204ac975c184b820b39",
  2174        "Running" : false,
  2175        "ExitCode" : 2,
  2176        "ProcessConfig" : {
  2177          "privileged" : false,
  2178          "user" : "",
  2179          "tty" : false,
  2180          "entrypoint" : "sh",
  2181          "arguments" : [
  2182            "-c",
  2183            "exit 2"
  2184          ]
  2185        },
  2186        "OpenStdin" : false,
  2187        "OpenStderr" : false,
  2188        "OpenStdout" : false,
  2189        "Container" : {
  2190          "State" : {
  2191            "Running" : true,
  2192            "Paused" : false,
  2193            "Restarting" : false,
  2194            "OOMKilled" : false,
  2195            "Pid" : 3650,
  2196            "ExitCode" : 0,
  2197            "Error" : "",
  2198            "StartedAt" : "2014-11-17T22:26:03.717657531Z",
  2199            "FinishedAt" : "0001-01-01T00:00:00Z"
  2200          },
  2201          "ID" : "8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c",
  2202          "Created" : "2014-11-17T22:26:03.626304998Z",
  2203          "Path" : "date",
  2204          "Args" : [],
  2205          "Config" : {
  2206            "Hostname" : "8f177a186b97",
  2207            "Domainname" : "",
  2208            "User" : "",
  2209            "AttachStdin" : false,
  2210            "AttachStdout" : false,
  2211            "AttachStderr" : false,
  2212            "ExposedPorts" : null,
  2213            "Tty" : false,
  2214            "OpenStdin" : false,
  2215            "StdinOnce" : false,
  2216            "Env" : [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ],
  2217            "Cmd" : [
  2218              "date"
  2219            ],
  2220            "Image" : "ubuntu",
  2221            "Volumes" : null,
  2222            "WorkingDir" : "",
  2223            "Entrypoint" : null,
  2224            "NetworkDisabled" : false,
  2225            "MacAddress" : "",
  2226            "OnBuild" : null,
  2227            "SecurityOpt" : null
  2228          },
  2229          "Image" : "5506de2b643be1e6febbf3b8a240760c6843244c41e12aa2f60ccbb7153d17f5",
  2230          "NetworkSettings" : {
  2231            "IPAddress" : "172.17.0.2",
  2232            "IPPrefixLen" : 16,
  2233            "MacAddress" : "02:42:ac:11:00:02",
  2234            "Gateway" : "172.17.42.1",
  2235            "Bridge" : "docker0",
  2236            "PortMapping" : null,
  2237            "Ports" : {}
  2238          },
  2239          "ResolvConfPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/resolv.conf",
  2240          "HostnamePath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hostname",
  2241          "HostsPath" : "/var/lib/docker/containers/8f177a186b977fb451136e0fdf182abff5599a08b3c7f6ef0d36a55aaf89634c/hosts",
  2242          "LogPath": "/var/lib/docker/containers/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b/1eb5fabf5a03807136561b3c00adcd2992b535d624d5e18b6cdc6a6844d9767b-json.log",
  2243          "Name" : "/test",
  2244          "Driver" : "aufs",
  2245          "ExecDriver" : "native-0.2",
  2246          "MountLabel" : "",
  2247          "ProcessLabel" : "",
  2248          "AppArmorProfile" : "",
  2249          "RestartCount" : 0,
  2250          "Mounts" : [],
  2251        }
  2252      }
  2253  
  2254  Status Codes:
  2255  
  2256  -   **200** – no error
  2257  -   **404** – no such exec instance
  2258  -   **500** - server error
  2259  
  2260  # 3. Going further
  2261  
  2262  ## 3.1 Inside `docker run`
  2263  
  2264  As an example, the `docker run` command line makes the following API calls:
  2265  
  2266  - Create the container
  2267  
  2268  - If the status code is 404, it means the image doesn't exist:
  2269      - Try to pull it.
  2270      - Then, retry to create the container.
  2271  
  2272  - Start the container.
  2273  
  2274  - If you are not in detached mode:
  2275  - Attach to the container, using `logs=1` (to have `stdout` and
  2276        `stderr` from the container's start) and `stream=1`
  2277  
  2278  - If in detached mode or only `stdin` is attached, display the container's id.
  2279  
  2280  ## 3.2 Hijacking
  2281  
  2282  In this version of the API, `/attach`, uses hijacking to transport `stdin`,
  2283  `stdout`, and `stderr` on the same socket.
  2284  
  2285  To hint potential proxies about connection hijacking, Docker client sends
  2286  connection upgrade headers similarly to websocket.
  2287  
  2288      Upgrade: tcp
  2289      Connection: Upgrade
  2290  
  2291  When Docker daemon detects the `Upgrade` header, it switches its status code
  2292  from **200 OK** to **101 UPGRADED** and resends the same headers.
  2293  
  2294  
  2295  ## 3.3 CORS Requests
  2296  
  2297  To set cross origin requests to the remote api please give values to 
  2298  `--api-cors-header` when running Docker in daemon mode. Set * (asterisk) allows all,
  2299  default or blank means CORS disabled
  2300  
  2301      $ docker daemon -H="192.168.1.9:2375" --api-cors-header="http://foo.bar"