github.com/ctmnz/docker@v1.6.0-rc3/docs/sources/reference/api/docker_remote_api_v1.18.md (about)

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