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