github.com/olljanat/moby@v1.13.1/docs/api/v1.20.md (about)

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