github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/docs/reference/api/docker_remote_api_v1.18.md (about)

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