github.com/kobeld/docker@v1.12.0-rc1/docs/reference/api/docker_remote_api_v1.19.md (about)

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