github.com/SophiaGitHub/hello@v1.7.1-rc3/docs/reference/api/docker_remote_api_v1.18.md (about)

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