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