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