github.com/netbrain/docker@v1.9.0-rc2/docs/reference/api/docker_remote_api_v1.21.md (about)

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