github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/docs/reference/api/docker_remote_api_v1.21.md (about)

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